Skip to content

Commit

Permalink
Merge pull request apache#569 from pwendell/merge-fixes.
Browse files Browse the repository at this point in the history
Fixes bug where merges won't close associated pull request.

Previously we added "Closes #XX" in the title. Github will sometimes
linbreak the title in a way that causes this to not work. This patch
instead adds the line in the body.

This also makes the commit format more concise for merge commits.
We might consider just dropping those in the future.

Author: Patrick Wendell <[email protected]>

Closes apache#569 and squashes the following commits:

732eba1 [Patrick Wendell] Fixes bug where merges won't close associated pull request.
  • Loading branch information
pwendell authored and rxin committed Feb 9, 2014
1 parent b69f8b2 commit 94ccf86
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions dev/merge_spark_pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,20 @@ def merge_pr(pr_num, target_ref):
'--pretty=format:%an <%ae>']).split("\n")
distinct_authors = sorted(set(commit_authors), key=lambda x: commit_authors.count(x), reverse=True)
primary_author = distinct_authors[0]
commits = run_cmd(['git', 'log', 'HEAD..%s' % pr_branch_name]).split("\n\n")
commits = run_cmd(['git', 'log', 'HEAD..%s' % pr_branch_name,
'--pretty=format:%h [%an] %s']).split("\n\n")

merge_message = "Merge pull request #%s from %s. Closes #%s.\n\n%s\n\n%s" % (
pr_num, pr_repo_desc, pr_num, title, body)
merge_message = "Merge pull request #%s from %s.\n\n%s\n\n%s" % (
pr_num, pr_repo_desc, title, body)
merge_message_parts = merge_message.split("\n\n")
merge_message_flags = []

for p in merge_message_parts:
merge_message_flags = merge_message_flags + ["-m", p]
authors = "\n".join(["Author: %s" % a for a in distinct_authors])
merge_message_flags = merge_message_flags + ["-m", authors]
merge_message_flags = merge_message_flags + ["-m", "== Merge branch commits =="]
merge_message_flags = merge_message_flags + [
"-m", "Closes #%s and squashes the following commits:" % pr_num]
for c in commits:
merge_message_flags = merge_message_flags + ["-m", c]

Expand Down

0 comments on commit 94ccf86

Please sign in to comment.