[llvm] Changed Regex to accept /branch: and /cherry-pick: commands (PR #81002)

Shourya Goel via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 1 21:54:38 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/2] 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/2] 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()



More information about the llvm-commits mailing list