1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

sync_default_gems.rb: fix the position to insert the original URL

Since the regexp had expected an empty line before `Co-Authored-By:`
trailer lines, it failed to match when the body has the trailer only.
This commit is contained in:
Nobuyoshi Nakada 2022-11-04 15:18:36 +09:00
parent 570dee15a6
commit b6d7e98f25
No known key found for this signature in database
GPG key ID: 7CD2805BFA3770C6

View file

@ -441,9 +441,10 @@ def message_filter(repo, sha, input: ARGF)
end
url = "#{url}/commit/#{sha[0,10]}\n"
if log and !log.empty?
log.sub!(/(?<=\n)\n+\z/, '') # drop empty lines at the last
conv[log]
log.sub!(/\s*(?=(?i:\nCo-authored-by:.*)*\Z)/) {
"\n\n#{url}"
log.sub!(/(?:(\A\s*)|\s*\n)(?=(?i:Co-authored-by:.*)*\Z)/) {
$~.begin(0) ? "#{url}\n" : "\n\n#{url}"
}
else
log = url