aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2022-11-04 15:18:36 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2022-11-04 15:43:29 +0900
commitb6d7e98f2540500f072c5cc0f136cae69f80055c (patch)
tree672511d0237c5cb05033c4ddebb2d0e434ae2d58
parent570dee15a6939f1a3c8cf301202a1c508c2c2a33 (diff)
downloadruby-b6d7e98f2540500f072c5cc0f136cae69f80055c.tar.gz
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.
-rwxr-xr-xtool/sync_default_gems.rb5
1 files changed, 3 insertions, 2 deletions
diff --git a/tool/sync_default_gems.rb b/tool/sync_default_gems.rb
index d6b20a82bf..80eabab81c 100755
--- a/tool/sync_default_gems.rb
+++ b/tool/sync_default_gems.rb
@@ -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