Listing of PR commits in commit message should be optional

If there is a single commit in the PR, then it's never listed.
This commit is contained in:
Ismael Juma 2015-08-13 18:30:14 +01:00
parent 78685dc162
commit 64f1aecf5d
1 changed files with 17 additions and 6 deletions

View File

@ -140,7 +140,16 @@ def merge_pr(pr_num, target_ref, title, body, pr_repo_desc):
"Enter reviewers in the format of \"name1 <email1>, name2 <email2>\": ").strip() "Enter reviewers in the format of \"name1 <email1>, name2 <email2>\": ").strip()
commits = run_cmd(['git', 'log', 'HEAD..%s' % pr_branch_name, commits = run_cmd(['git', 'log', 'HEAD..%s' % pr_branch_name,
'--pretty=format:%h [%an] %s']).split("\n\n") '--pretty=format:%h [%an] %s']).split("\n")
if len(commits) > 1:
result = raw_input("List pull request commits in squashed commit message? (y/n): ")
if result.lower() == "y":
should_list_commits = True
else:
should_list_commits = False
else:
should_list_commits = False
merge_message_flags = [] merge_message_flags = []
@ -165,11 +174,13 @@ def merge_pr(pr_num, target_ref, title, body, pr_repo_desc):
merge_message_flags += ["-m", message] merge_message_flags += ["-m", message]
# The string "Closes #%s" string is required for GitHub to correctly close the PR # The string "Closes #%s" string is required for GitHub to correctly close the PR
merge_message_flags += [ close_line = "Closes #%s from %s" % (pr_num, pr_repo_desc)
"-m", if should_list_commits:
"Closes #%s from %s and squashes the following commits:" % (pr_num, pr_repo_desc)] close_line += " and squashes the following commits:"
for c in commits: merge_message_flags += ["-m", close_line]
merge_message_flags += ["-m", c]
if should_list_commits:
merge_message_flags += ["-m", "\n".join(commits)]
run_cmd(['git', 'commit', '--author="%s"' % primary_author] + merge_message_flags) run_cmd(['git', 'commit', '--author="%s"' % primary_author] + merge_message_flags)