Fix the case of multiple trailers

This commit is contained in:
Nobuyoshi Nakada 2022-11-28 14:50:20 +09:00
Родитель 5a171ee4c0
Коммит 93e87c0217
2 изменённых файлов: 13 добавлений и 2 удалений

Просмотреть файл

@ -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

Просмотреть файл

@ -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