summaryrefslogtreecommitdiff
path: root/tool
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2022-11-28 14:50:20 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2022-11-28 16:30:40 +0900
commit93e87c0217a20dff53dfc576de913620021f83e6 (patch)
treefad1de1f4920c91244adf28db9c5787b8ab679cb /tool
parent5a171ee4c05c0ed20ac4b4632e54b23717d5fe16 (diff)
Fix the case of multiple trailers
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/6820
Diffstat (limited to 'tool')
-rwxr-xr-xtool/sync_default_gems.rb4
-rwxr-xr-xtool/test/test_sync_default_gems.rb11
2 files changed, 13 insertions, 2 deletions
diff --git a/tool/sync_default_gems.rb b/tool/sync_default_gems.rb
index 98894f52f4..4181b814f3 100755
--- a/tool/sync_default_gems.rb
+++ b/tool/sync_default_gems.rb
@@ -450,8 +450,8 @@ def message_filter(repo, sha, input: ARGF)
if log and !log.empty?
log.sub!(/(?<=\n)\n+\z/, '') # drop empty lines at the last
conv[log]
- log.sub!(/(?:(\A\s*)|\s*\n)(?=(?i:Co-authored-by:.*)*\Z)/) {
- $~.begin(1) ? "#{commit_url}\n" : "\n\n#{commit_url}"
+ log.sub!(/(?:(\A\s*)|\s*\n)(?=((?i:Co-authored-by:.*\n)+)?\Z)/) {
+ ($~.begin(1) ? "" : "\n\n") + commit_url + ($~.begin(2) ? "\n" : "")
}
else
log = commit_url
diff --git a/tool/test/test_sync_default_gems.rb b/tool/test/test_sync_default_gems.rb
index 7e6a6d830e..602598c3e3 100755
--- a/tool/test/test_sync_default_gems.rb
+++ b/tool/test/test_sync_default_gems.rb
@@ -51,5 +51,16 @@ module Test_SyncDefaultGems
]
assert_message_filter(expected, trailers, [expected, "", trailers, ""].join("\n"))
end
+
+ def test_multiple_co_authored_by
+ expected = [
+ "many commits",
+ ]
+ trailers = [
+ "Co-authored-by: git <git@ruby-lang.org>",
+ "Co-authored-by: svn <svn@ruby-lang.org>",
+ ]
+ assert_message_filter(expected, trailers, [expected, "", trailers, ""].join("\n"))
+ end
end
end