Skip to content

Commit

Permalink
Fix the case trailer without newline
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu committed Dec 21, 2022
1 parent 98fbebf commit 398aaed
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tool/sync_default_gems.rb
Expand Up @@ -466,13 +466,13 @@ 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:.*\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
Expand Down
10 changes: 10 additions & 0 deletions tool/test/test_sync_default_gems.rb
Expand Up @@ -62,5 +62,15 @@ def test_multiple_co_authored_by
]
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

0 comments on commit 398aaed

Please sign in to comment.