[llvm] [workflows] Create a more descriptive title and body when creating a … (PR #80396)
Tom Stellard via llvm-commits
llvm-commits at lists.llvm.org
Sat Feb 3 16:12:42 PST 2024
https://github.com/tstellar updated https://github.com/llvm/llvm-project/pull/80396
>From 5c1774f408b2c45a353a2a5a538d25a2787e384a Mon Sep 17 00:00:00 2001
From: Tom Stellard <tstellar at redhat.com>
Date: Fri, 2 Feb 2024 07:17:36 +0000
Subject: [PATCH 1/2] [workflows] Create a more descriptive title and body when
creating a PR for backports
When a backport request is made, the resulting pull request will have a
title like this:
Backport <commit> <commit> .. <First line of HEAD commit for the branch>
And a body that is the commit message of the HEAD commit for the branch
(minus the first line).
---
llvm/utils/git/github-automation.py | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/llvm/utils/git/github-automation.py b/llvm/utils/git/github-automation.py
index 04698cacbff92..f7eaf1f3ec550 100755
--- a/llvm/utils/git/github-automation.py
+++ b/llvm/utils/git/github-automation.py
@@ -536,7 +536,7 @@ def create_branch(self, commits: List[str]) -> bool:
self.issue_remove_cherry_pick_failed_label()
return self.create_pull_request(
- self.branch_repo_owner, self.repo_name, branch_name
+ self.branch_repo_owner, self.repo_name, branch_name, commits
)
def check_if_pull_request_exists(
@@ -545,7 +545,7 @@ def check_if_pull_request_exists(
pulls = repo.get_pulls(head=head)
return pulls.totalCount != 0
- def create_pull_request(self, owner: str, repo_name: str, branch: str) -> bool:
+ def create_pull_request(self, owner: str, repo_name: str, branch: str, commits: List[str]) -> bool:
"""
Create a pull request in `self.repo_name`. The base branch of the
pull request will be chosen based on the the milestone attached to
@@ -567,9 +567,15 @@ def create_pull_request(self, owner: str, repo_name: str, branch: str) -> bool:
print("PR already exists...")
return True
try:
+ commit_message = repo.get_commit(commits[-1]).commit.message
+ message_lines = commit_message.splitlines()
+ body = ""
+ if len(message_lines) > 1:
+ body = "".join(message_lines.splitlines()[1:])
+ title = "Backport {} {}".format(" ".join(commits), message_lines[0])
pull = repo.create_pull(
- title=f"PR for {issue_ref}",
- body="resolves {}".format(issue_ref),
+ title=title,
+ body=body,
base=release_branch_for_issue,
head=head,
maintainer_can_modify=False,
>From 90ed7c04f5c7ec5190899703fb6ec11ace8f9826 Mon Sep 17 00:00:00 2001
From: Tom Stellard <tstellar at redhat.com>
Date: Sat, 3 Feb 2024 23:38:10 +0000
Subject: [PATCH 2/2] Adjust title and description
---
llvm/utils/git/github-automation.py | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/llvm/utils/git/github-automation.py b/llvm/utils/git/github-automation.py
index f7eaf1f3ec550..0610d40b64ac7 100755
--- a/llvm/utils/git/github-automation.py
+++ b/llvm/utils/git/github-automation.py
@@ -569,10 +569,8 @@ def create_pull_request(self, owner: str, repo_name: str, branch: str, commits:
try:
commit_message = repo.get_commit(commits[-1]).commit.message
message_lines = commit_message.splitlines()
- body = ""
- if len(message_lines) > 1:
- body = "".join(message_lines.splitlines()[1:])
- title = "Backport {} {}".format(" ".join(commits), message_lines[0])
+ title = "{}: {}".format(release_branch_for_issue, message_lines[0])
+ body = "Backport {}".format(" ".join(commits))
pull = repo.create_pull(
title=title,
body=body,
More information about the llvm-commits
mailing list