Skip to content

Commit

Permalink
KAFKA-2430; Listing of PR commits in commit message should be optional
Browse files Browse the repository at this point in the history
If there is a single commit in the PR, then it's never listed.

Author: Ismael Juma <[email protected]>

Reviewers: Guozhang Wang

Closes apache#136 from ijuma/kafka-2430-optional-listing-commits and squashes the following commits:

64f1aec [Ismael Juma] Listing of PR commits in commit message should be optional
  • Loading branch information
ijuma authored and guozhangwang committed Aug 13, 2015
1 parent 78685dc commit e2ebae8
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions kafka-merge-pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

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 = []

Expand All @@ -165,11 +174,13 @@ def merge_pr(pr_num, target_ref, title, body, pr_repo_desc):
merge_message_flags += ["-m", message]

# The string "Closes #%s" string is required for GitHub to correctly close the PR
merge_message_flags += [
"-m",
"Closes #%s from %s and squashes the following commits:" % (pr_num, pr_repo_desc)]
for c in commits:
merge_message_flags += ["-m", c]
close_line = "Closes #%s from %s" % (pr_num, pr_repo_desc)
if should_list_commits:
close_line += " and squashes the following commits:"
merge_message_flags += ["-m", close_line]

if should_list_commits:
merge_message_flags += ["-m", "\n".join(commits)]

run_cmd(['git', 'commit', '--author="%s"' % primary_author] + merge_message_flags)

Expand Down

0 comments on commit e2ebae8

Please sign in to comment.