diff options
author | Takashi Kokubun <takashikkbn@gmail.com> | 2022-11-25 21:45:27 -0800 |
---|---|---|
committer | Takashi Kokubun <takashikkbn@gmail.com> | 2022-11-25 21:45:28 -0800 |
commit | 29bf5495a9ecb2b70cd1fc9008e1b861e982ab72 (patch) | |
tree | ee4ed83958585ac8863965946c5c959b078c7aaf /tool/sync_default_gems.rb | |
parent | 95647378ffdaa0ceb09595430b43534d3a7f3452 (diff) | |
download | ruby-29bf5495a9ecb2b70cd1fc9008e1b861e982ab72.tar.gz |
Do not use the same variable for multiple things
`conv` proc is used before and after the `url` variable is updated. So
this script didn't seem to behave correctly for the "Close #xxx" syntax.
Reusing the same variable name for different things seems prone to errors.
Diffstat (limited to 'tool/sync_default_gems.rb')
-rwxr-xr-x | tool/sync_default_gems.rb | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/tool/sync_default_gems.rb b/tool/sync_default_gems.rb index c8d72a2abf..06852cccbe 100755 --- a/tool/sync_default_gems.rb +++ b/tool/sync_default_gems.rb @@ -424,11 +424,11 @@ IGNORE_FILE_PATTERN = def message_filter(repo, sha, input: ARGF) log = input.read log.delete!("\r") - url = "https://github.com/#{repo}" + repo_url = "https://github.com/#{repo}" subject, log = log.split(/\n(?:[\s\t]*(?:\n|\z))/, 2) conv = proc do |s| mod = true if s.gsub!(/\b(?:(?i:fix(?:e[sd])?|close[sd]?|resolve[sd]?) +)\K#(?=\d+\b)|\bGH-#?(?=\d+\b)|\(\K#(?=\d+\))/) { - "#{url}/pull/" + "#{repo_url}/pull/" } mod |= true if s.gsub!(%r{(?<![-\[\](){}\w@/])(?:(\w+(?:-\w+)*/\w+(?:-\w+)*)@)?(\h{10,40})\b}) {|c| "https://github.com/#{$1 || repo}/commit/#{$2[0,12]}" @@ -442,15 +442,15 @@ def message_filter(repo, sha, input: ARGF) subject.gsub!(/\G.{,67}[^\s.,][.,]*\K\s+/, "\n") end end - url = "#{url}/commit/#{sha[0,10]}\n" + commit_url = "#{repo_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!(/(?:(\A\s*)|\s*\n)(?=(?i:Co-authored-by:.*)*\Z)/) { - $~.begin(1) ? "#{url}\n" : "\n\n#{url}" + $~.begin(1) ? "#{commit_url}\n" : "\n\n#{commit_url}" } else - log = url + log = commit_url end print subject, "\n\n", log end |