summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhuohao Lee <zhuohao@chromium.org>2022-05-17 11:25:50 +0800
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-05-17 07:56:34 +0000
commite2d0f0a288d91f357296613ab3a2814fdd395792 (patch)
treecb9aa0e78344fe6e395f0d4cb332a6476aded19f
parent6e3ee258076879a389eb4b8f0c12be8d12e4b262 (diff)
downloadchrome-ec-e2d0f0a288d91f357296613ab3a2814fdd395792.tar.gz
update_release_branch: add the "Generated by" to the commit message
In order to let everybody know how to generate the patch, it would be good to output the command to the commit message. This patch adds the "Generated by:" to the commit message. BUG=None BRANCH=None TEST=`util/update_release_branch.py` to generate the message locally Change-Id: I640c41cc6838a14dbecc42d993afcf1967e466c0 Signed-off-by: Zhuohao Lee <zhuohao@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3650297 Reviewed-by: caveh jalali <caveh@chromium.org> Reviewed-by: Boris Mittelberg <bmbm@google.com>
-rwxr-xr-xutil/update_release_branch.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/util/update_release_branch.py b/util/update_release_branch.py
index 75163db877..b9063d4970 100755
--- a/util/update_release_branch.py
+++ b/util/update_release_branch.py
@@ -23,7 +23,7 @@ import textwrap
BUG_NONE_PATTERN = re.compile('none', flags=re.IGNORECASE)
-def git_commit_msg(branch, head, merge_head, rel_paths):
+def git_commit_msg(branch, head, merge_head, rel_paths, cmd):
"""Generates a merge commit message based off of relevant changes.
This function obtains the relevant commits from the given relative paths in
@@ -36,6 +36,7 @@ def git_commit_msg(branch, head, merge_head, rel_paths):
merge_head: String indicating the merge branch refspec.
rel_paths: String containing all the relevant paths for this particular
baseboard or board.
+ cmd: String of the input command.
Returns:
A String containing the git commit message with the exception of the
@@ -63,6 +64,8 @@ def git_commit_msg(branch, head, merge_head, rel_paths):
COMMIT_MSG_TEMPLATE = """
Merge remote-tracking branch cros/main into {BRANCH}
+Generated by: {COMMAND_LINE}
+
Relevant changes:
{RELEVANT_COMMITS_CMD}
@@ -89,7 +92,8 @@ Cq-Include-Trybots: chromeos/cq:cq-orchestrator
return COMMIT_MSG_TEMPLATE.format(BRANCH=branch,
RELEVANT_COMMITS_CMD=relevant_commits_cmd,
RELEVANT_COMMITS=relevant_commits,
- BUG_FIELD=bug_field)
+ BUG_FIELD=bug_field,
+ COMMAND_LINE=cmd)
def get_relevant_boards(baseboard):
@@ -182,7 +186,7 @@ def main(argv):
help=('The strategy option for the chosen merge '
'strategy'))
- opts = parser.parse_args(argv)
+ opts = parser.parse_args(argv[1:])
baseboard_dir = ''
board_dir = ''
@@ -259,8 +263,9 @@ def main(argv):
encoding='utf-8',
check=True).stdout.rstrip()
+ cmd = ' '.join(argv)
print('Typing as fast as I can...')
- commit_msg = git_commit_msg(branch, head, merge_head, relevant_paths)
+ commit_msg = git_commit_msg(branch, head, merge_head, relevant_paths, cmd)
subprocess.run(['git', 'commit', '--signoff', '-m', commit_msg], check=True)
subprocess.run(['git', 'commit', '--amend'], check=True)
print(("Finished! **Please review the commit to see if it's to your "
@@ -268,4 +273,4 @@ def main(argv):
if __name__ == '__main__':
- main(sys.argv[1:])
+ main(sys.argv)