[llvm] Changed Regex to accept /branch: and /cherry-pick: commands (PR #81002)
Shourya Goel via llvm-commits
llvm-commits at lists.llvm.org
Sat Mar 2 00:34:51 PST 2024
https://github.com/Sh0g0-1758 updated https://github.com/llvm/llvm-project/pull/81002
>From 6ec2d323b8be4a2b6edd91ac6d6791d917bc29a2 Mon Sep 17 00:00:00 2001
From: Sh0g0-1758 <shouryagoel10000 at gmail.com>
Date: Wed, 7 Feb 2024 20:54:17 +0530
Subject: [PATCH 1/3] Changed Regex to accept /branch: and /cherry-pick:
commands
---
llvm/utils/git/github-automation.py | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/llvm/utils/git/github-automation.py b/llvm/utils/git/github-automation.py
index e2b84aeca3ad7a..7eb76e435b3f34 100755
--- a/llvm/utils/git/github-automation.py
+++ b/llvm/utils/git/github-automation.py
@@ -603,16 +603,16 @@ def execute_command(self) -> bool:
"""
This function reads lines from STDIN and executes the first command
that it finds. The 2 supported commands are:
- /cherry-pick commit0 <commit1> <commit2> <...>
- /branch <owner>/<repo>/<branch>
+ /cherry-pick<:> commit0 <commit1> <commit2> <...>
+ /branch<:> <owner>/<repo>/<branch>
"""
for line in sys.stdin:
line.rstrip()
- m = re.search(r"/([a-z-]+)\s(.+)", line)
+ m = re.search(r"/([a-z-]+)(:?)(?:\s(.+))?", line)
if not m:
continue
command = m.group(1)
- args = m.group(2)
+ args = m.group(3)
if command == "cherry-pick":
arg_list = args.split()
>From f449793e759414109fa999a11a421cb245f40915 Mon Sep 17 00:00:00 2001
From: Sh0g0-1758 <shouryagoel10000 at gmail.com>
Date: Wed, 7 Feb 2024 22:20:37 +0530
Subject: [PATCH 2/3] Changed Regex to include space also
---
llvm/utils/git/github-automation.py | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/llvm/utils/git/github-automation.py b/llvm/utils/git/github-automation.py
index 7eb76e435b3f34..74e86a4fbdf2a3 100755
--- a/llvm/utils/git/github-automation.py
+++ b/llvm/utils/git/github-automation.py
@@ -603,16 +603,16 @@ def execute_command(self) -> bool:
"""
This function reads lines from STDIN and executes the first command
that it finds. The 2 supported commands are:
- /cherry-pick<:> commit0 <commit1> <commit2> <...>
- /branch<:> <owner>/<repo>/<branch>
+ /cherry-pick< ><:> commit0 <commit1> <commit2> <...>
+ /branch< ><:> <owner>/<repo>/<branch>
"""
for line in sys.stdin:
line.rstrip()
- m = re.search(r"/([a-z-]+)(:?)(?:\s(.+))?", line)
+ m = re.search(r"/([a-z-]+)\s*:? *(.*)", line)
if not m:
continue
command = m.group(1)
- args = m.group(3)
+ args = m.group(2)
if command == "cherry-pick":
arg_list = args.split()
>From 55e768b65b325aeab55607c2a4dda0216b906b81 Mon Sep 17 00:00:00 2001
From: Sh0g0-1758 <shouryagoel10000 at gmail.com>
Date: Sat, 2 Mar 2024 14:04:37 +0530
Subject: [PATCH 3/3] Removed Branch command
---
llvm/utils/git/github-automation.py | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/llvm/utils/git/github-automation.py b/llvm/utils/git/github-automation.py
index 6a9fe3f586896a..0dbc7b925dbc94 100755
--- a/llvm/utils/git/github-automation.py
+++ b/llvm/utils/git/github-automation.py
@@ -616,9 +616,8 @@ def create_pull_request(
def execute_command(self) -> bool:
"""
This function reads lines from STDIN and executes the first command
- that it finds. The 2 supported commands are:
+ that it finds. The supported command is:
/cherry-pick< ><:> commit0 <commit1> <commit2> <...>
- /branch< ><:> <owner>/<repo>/<branch>
"""
for line in sys.stdin:
line.rstrip()
@@ -628,10 +627,9 @@ def execute_command(self) -> bool:
command = m.group(1)
args = m.group(2)
- if command == "cherry-pick":
- arg_list = args.split()
- commits = list(map(lambda a: extract_commit_hash(a), arg_list))
- return self.create_branch(commits)
+ arg_list = args.split()
+ commits = list(map(lambda a: extract_commit_hash(a), arg_list))
+ return self.create_branch(commits)
print("Do not understand input:")
print(sys.stdin.readlines())
More information about the llvm-commits
mailing list