Repository: spark Updated Branches: refs/heads/master 18b6ec147 -> 51bee7aca
[SPARK-25018][INFRA] Use `Co-authored-by` and `Signed-off-by` git trailer in `merge_spark_pr.py` ## What changes were proposed in this pull request? In [Linux community](https://git.wiki.kernel.org/index.php/CommitMessageConventions), `Co-authored-by` and `Signed-off-by` git trailer have been used for awhile. Until recently, Github adopted `Co-authored-by` to include the work of co-authors in the profile contributions graph and the repository's statistics. It's a convention for recognizing multiple authors, and can encourage people to collaborate in OSS communities. Git provides a command line tools to read the metadata to know who commits the code to upstream, but it's not as easy as having `Signed-off-by` as part of the message so developers can find who is the relevant committers who can help with certain part of the codebase easier. For a single author PR, I purpose to use `Authored-by` and `Signed-off-by`, so the message will look like ``` Authored-by: Author's name <authorexample.com> Signed-off-by: Committer's name <committerexample.com> ``` For a multi-author PR, I purpose to use `Lead-authored-by:` and `Co-authored-by:` for the lead author and co-authors. The message will look like ``` Lead-authored-by: Lead Author's name <leadauthorexample.com> Co-authored-by: CoAuthor's name <coauthorexample.com> Signed-off-by: Committer's name <committerexample.com> ``` It's also useful to include `Reviewed-by:` to give credits to the people who participate on the code reviewing. We can add this in the next iteration. Closes #21991 from dbtsai/script. Lead-authored-by: DB Tsai <d_t...@apple.com> Co-authored-by: Liang-Chi Hsieh <vii...@gmail.com> Co-authored-by: Brian Lindblom <blindb...@apple.com> Co-authored-by: hyukjinkwon <gurwls...@apache.org> Signed-off-by: hyukjinkwon <gurwls...@apache.org> Project: http://git-wip-us.apache.org/repos/asf/spark/repo Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/51bee7ac Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/51bee7ac Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/51bee7ac Branch: refs/heads/master Commit: 51bee7aca13451167fa3e701fcd60f023eae5e61 Parents: 18b6ec1 Author: DB Tsai <d_t...@apple.com> Authored: Tue Aug 7 10:31:11 2018 +0800 Committer: hyukjinkwon <gurwls...@apache.org> Committed: Tue Aug 7 10:31:11 2018 +0800 ---------------------------------------------------------------------- dev/merge_spark_pr.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/spark/blob/51bee7ac/dev/merge_spark_pr.py ---------------------------------------------------------------------- diff --git a/dev/merge_spark_pr.py b/dev/merge_spark_pr.py index fd3eeb0..7a6f7d2 100755 --- a/dev/merge_spark_pr.py +++ b/dev/merge_spark_pr.py @@ -142,6 +142,11 @@ def merge_pr(pr_num, target_ref, title, body, pr_repo_desc): distinct_authors[0]) if primary_author == "": primary_author = distinct_authors[0] + else: + # When primary author is specified manually, de-dup it from author list and + # put it at the head of author list. + distinct_authors = list(filter(lambda x: x != primary_author, distinct_authors)) + distinct_authors.insert(0, primary_author) commits = run_cmd(['git', 'log', 'HEAD..%s' % pr_branch_name, '--pretty=format:%h [%an] %s']).split("\n\n") @@ -154,13 +159,10 @@ 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] @@ -168,6 +170,14 @@ def merge_pr(pr_num, target_ref, title, body, pr_repo_desc): # 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 = "Authored-by:" if len(distinct_authors) == 1 else "Lead-authored-by:" + authors += " %s" % (distinct_authors.pop(0)) + if len(distinct_authors) > 0: + authors += "\n" + "\n".join(["Co-authored-by: %s" % a for a in distinct_authors]) + 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?" % ( --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org For additional commands, e-mail: commits-h...@spark.apache.org