Skip to content
12 changes: 7 additions & 5 deletions dev/merge_spark_pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,20 +154,22 @@ def merge_pr(pr_num, target_ref, title, body, pr_repo_desc):
# to people every time someone creates a public fork of Spark.
merge_message_flags += ["-m", body.replace("@", "")]

authors = "\n".join(["Author: %s" % a for a in distinct_authors])

merge_message_flags += ["-m", authors]
committer_name = run_cmd("git config --get user.name").strip()
committer_email = run_cmd("git config --get user.email").strip()

if had_conflicts:
committer_name = run_cmd("git config --get user.name").strip()
committer_email = run_cmd("git config --get user.email").strip()
message = "This patch had conflicts when merged, resolved by\nCommitter: %s <%s>" % (
committer_name, committer_email)
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." % (pr_num, pr_repo_desc)]

authors = "\n".join(["Co-authored-by: %s" % a for a in distinct_authors])
Copy link
Member Author

@dbtsai dbtsai Aug 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For single author commit, should we do Authored-by instead of Co-authored-by?

Or we can have the first author as Authored-by like the following.

Authored-by: David <[email protected]>
Co-authored-by: Bill <[email protected]>

Copy link
Member

@felixcheung felixcheung Aug 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or leave it as before Author: to be safe?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these particular keys have a meaning to github or other tools? if "Author:" is what something is looking for, we'd want to leave it, I presume. But adding more lines for co-authors seems fine. I would have just listed multiple "Author:" lines, but sounds like there's another convention around "Co-authored-by:" that another tool looks for?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems that those keys are widely used in Linux community for a long time, and Github adopted Co-authored-by to include the work of cu-authoers in the profile contributions graph and the repository's statistics.

This has to be in the end of the message, and Github will just ignore those keys that are not recognized.

If we want to keep both multiple lines of Author: and Co-authored-by:, the information will be duplicated twice. I would like to purpose to just keep Co-authored-by:. For single developer commit, we can just use Authored-by: for consistency.

authors += "\n" + "Signed-off-by: %s <%s>" % (committer_name, committer_email)

merge_message_flags += ["-m", authors]

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

continue_maybe("Merge complete (local ref %s). Push to %s?" % (
Expand Down