From 2563311b2b52fb7ca886f7feca1b3d5dcf786e9c Mon Sep 17 00:00:00 2001 From: DB Tsai Date: Fri, 3 Aug 2018 10:52:43 -0700 Subject: [PATCH 1/9] Use co-author-by --- dev/merge_spark_pr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/merge_spark_pr.py b/dev/merge_spark_pr.py index fd3eeb007a845..37ce8013941aa 100755 --- a/dev/merge_spark_pr.py +++ b/dev/merge_spark_pr.py @@ -154,7 +154,7 @@ 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]) + authors = "\n".join(["Co-Authored-By: %s" % a for a in distinct_authors]) merge_message_flags += ["-m", authors] From 6732913905906743fda9842999d6c9c45dd6134a Mon Sep 17 00:00:00 2001 From: DB Tsai Date: Fri, 3 Aug 2018 15:03:26 -0700 Subject: [PATCH 2/9] added signed-off-by --- dev/merge_spark_pr.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/dev/merge_spark_pr.py b/dev/merge_spark_pr.py index 37ce8013941aa..93c2473c484cc 100755 --- a/dev/merge_spark_pr.py +++ b/dev/merge_spark_pr.py @@ -154,13 +154,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(["Co-Authored-By: %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 +165,11 @@ 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 = "\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?" % ( From fbd8cb4c25dc867d1c08eef83ac935bf3af816e3 Mon Sep 17 00:00:00 2001 From: DB Tsai Date: Sun, 5 Aug 2018 23:19:07 -0700 Subject: [PATCH 3/9] lead-authored-by --- dev/merge_spark_pr.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dev/merge_spark_pr.py b/dev/merge_spark_pr.py index 93c2473c484cc..0bc28545e12bf 100755 --- a/dev/merge_spark_pr.py +++ b/dev/merge_spark_pr.py @@ -165,7 +165,10 @@ 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 = "\n".join(["Co-authored-by: %s" % a for a in distinct_authors]) + authors = "Authored-by:" if len(distinct_authors) == 1 else "Lead-authored-by:" + authors += " %s <%s>" % (committer_name, committer_email) + distinct_authors.pop(0) + authors += "\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] From c5cd418d208ce63b6fa03979e492c9ee7848915d Mon Sep 17 00:00:00 2001 From: hyukjinkwon Date: Mon, 6 Aug 2018 20:43:43 +0800 Subject: [PATCH 4/9] Empty commit to test 'Co-authored-by' and 'Signed-off-by' From 4500d608a6ef20b358b2f41e068a2ceda88ee9cf Mon Sep 17 00:00:00 2001 From: DB Tsai Date: Mon, 6 Aug 2018 10:23:05 -0700 Subject: [PATCH 5/9] Added new line --- dev/merge_spark_pr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/merge_spark_pr.py b/dev/merge_spark_pr.py index 0bc28545e12bf..ed4ef352435a3 100755 --- a/dev/merge_spark_pr.py +++ b/dev/merge_spark_pr.py @@ -166,7 +166,7 @@ def merge_pr(pr_num, target_ref, title, body, pr_repo_desc): 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 <%s>" % (committer_name, committer_email) + authors += " %s <%s>\n" % (committer_name, committer_email) distinct_authors.pop(0) authors += "\n".join(["Co-authored-by: %s" % a for a in distinct_authors]) authors += "\n" + "Signed-off-by: %s <%s>" % (committer_name, committer_email) From a69cfb379eca44db838f1f4a0224112cf2573d90 Mon Sep 17 00:00:00 2001 From: Brian Lindblom Date: Mon, 6 Aug 2018 10:50:52 -0700 Subject: [PATCH 6/9] add thrid author From 483d1828067f7f55cc80b2ce773596d66bd16ef8 Mon Sep 17 00:00:00 2001 From: DB Tsai Date: Mon, 6 Aug 2018 11:26:15 -0700 Subject: [PATCH 7/9] fix first author bug --- dev/merge_spark_pr.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dev/merge_spark_pr.py b/dev/merge_spark_pr.py index ed4ef352435a3..e04b6a7888d05 100755 --- a/dev/merge_spark_pr.py +++ b/dev/merge_spark_pr.py @@ -166,9 +166,9 @@ def merge_pr(pr_num, target_ref, title, body, pr_repo_desc): 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 <%s>\n" % (committer_name, committer_email) - distinct_authors.pop(0) - authors += "\n".join(["Co-authored-by: %s" % a for a in distinct_authors]) + 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] From cc67c8d7d4a07e4611a02063e9761714c1394db0 Mon Sep 17 00:00:00 2001 From: Liang-Chi Hsieh Date: Mon, 6 Aug 2018 22:13:51 +0000 Subject: [PATCH 8/9] Add manually given primary author at the head of author list. --- dev/merge_spark_pr.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dev/merge_spark_pr.py b/dev/merge_spark_pr.py index e04b6a7888d05..300795624a029 100755 --- a/dev/merge_spark_pr.py +++ b/dev/merge_spark_pr.py @@ -142,6 +142,9 @@ 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, put it at the head of author list. + distinct_authors.insert(0, primary_author) commits = run_cmd(['git', 'log', 'HEAD..%s' % pr_branch_name, '--pretty=format:%h [%an] %s']).split("\n\n") From 272d8fd4c6a46164069e2e3a892f016e9664cf5f Mon Sep 17 00:00:00 2001 From: Liang-Chi Hsieh Date: Mon, 6 Aug 2018 23:25:07 +0000 Subject: [PATCH 9/9] De-dup primary author from distinct author list. --- dev/merge_spark_pr.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dev/merge_spark_pr.py b/dev/merge_spark_pr.py index 300795624a029..7a6f7d2b891d3 100755 --- a/dev/merge_spark_pr.py +++ b/dev/merge_spark_pr.py @@ -143,7 +143,9 @@ def merge_pr(pr_num, target_ref, title, body, pr_repo_desc): if primary_author == "": primary_author = distinct_authors[0] else: - # When primary author is specified manually, put it at the head of author list. + # 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,