[PATCH] D151191: [llvm][github] Allow github links in /cherry-pick actions

Timm Bäder via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 23 01:26:17 PDT 2023


tbaeder created this revision.
tbaeder added reviewers: tstellar, thieta.
Herald added a project: All.
tbaeder requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151191

Files:
  llvm/utils/git/github-automation.py


Index: llvm/utils/git/github-automation.py
===================================================================
--- llvm/utils/git/github-automation.py
+++ llvm/utils/git/github-automation.py
@@ -155,6 +155,18 @@
     return accepted
 
 
+def extract_commit_hash(arg: str):
+    """
+    Extract the commit hash from the argument passed to /action github
+    comment actions. We currently only support passing the commit hash
+    directly or use the github URL, such as
+    https://github.com/llvm/llvm-project/commit/2832d7941f4207f1fcf813b27cf08cecc3086959
+    """
+    github_prefix = "https://github.com/llvm/llvm-project/commit/"
+    if arg.startswith(github_prefix):
+        return arg[len(github_prefix):]
+    return arg
+
 class ReleaseWorkflow:
 
     CHERRY_PICK_FAILED_LABEL = "release:cherry-pick-failed"
@@ -460,7 +472,9 @@
             args = m.group(2)
 
             if command == "cherry-pick":
-                return self.create_branch(args.split())
+                arg_list = args.split()
+                commits = list(map(lambda a: extract_commit_hash(a), arg_list))
+                return self.create_branch(commits)
 
             if command == "branch":
                 m = re.match("([^/]+)/([^/]+)/(.+)", args)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151191.524604.patch
Type: text/x-patch
Size: 1248 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230523/c43714b3/attachment.bin>


More information about the llvm-commits mailing list