Fix the case trailer without newline

cf0b413ef8b794ef6e7436f22fd5a998050dada9
This commit is contained in:
Nobuyoshi Nakada 2022-12-22 00:33:44 +09:00
parent 98fbebf110
commit 398aaed2f0
No known key found for this signature in database
GPG Key ID: 7CD2805BFA3770C6
2 changed files with 12 additions and 2 deletions

View File

@ -466,13 +466,13 @@ module SyncDefaultGems
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:.*\n)+)?\Z)/) {
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
end
print subject, "\n\n", log
puts subject, "\n", log
end
# NOTE: This method is also used by GitHub ruby/git.ruby-lang.org's bin/update-default-gem.sh

View File

@ -62,5 +62,15 @@ module Test_SyncDefaultGems
]
assert_message_filter(expected, trailers, [expected, "", trailers, ""].join("\n"))
end
def test_co_authored_by_no_newline
expected = [
"commit something",
]
trailers = [
"Co-Authored-By: git <git@ruby-lang.org>",
]
assert_message_filter(expected, trailers, [expected, "", trailers].join("\n"))
end
end
end