sync_default_gems.rb: fold too long subject [ci skip]

Line with substituted issue references with URLs are often very long.
Although Git (and GitHub) recommends folding subject lines less than
50 columns, but many commits ignore this, so fold at 68 columns for
now.
This commit is contained in:
Nobuyoshi Nakada 2022-10-18 12:13:06 +09:00
parent 93d73cfe80
commit e1ca90c2a4
No known key found for this signature in database
GPG Key ID: 7CD2805BFA3770C6

View File

@ -422,16 +422,30 @@ def message_filter(repo, sha)
log = STDIN.read log = STDIN.read
log.delete!("\r") log.delete!("\r")
url = "https://github.com/#{repo}" url = "https://github.com/#{repo}"
log.gsub!(/\b(?:(?i:fix(?:e[sd])?) +)\K#(?=\d+\b)|\bGH-#?(?=\d+\b)|\(\K#(?=\d+\))/) { subject, log = log.split("\n\n", 2)
"#{url}/pull/" conv = proc do |s|
} mod = true if s.gsub!(/\b(?:(?i:fix(?:e[sd])?) +)\K#(?=\d+\b)|\bGH-#?(?=\d+\b)|\(\K#(?=\d+\))/) {
log.gsub!(%r{(?<![-\[\](){}\w@/])(?:(\w+(?:-\w+)*/\w+(?:-\w+)*)@)?(\h{10,40})\b}) {|c| "#{url}/pull/"
"https://github.com/#{$1 || repo}/commit/#{$2[0,12]}" }
} mod |= true if s.gsub!(%r{(?<![-\[\](){}\w@/])(?:(\w+(?:-\w+)*/\w+(?:-\w+)*)@)?(\h{10,40})\b}) {|c|
log.sub!(/\s*(?=(?i:\nCo-authored-by:.*)*\Z)/) { "https://github.com/#{$1 || repo}/commit/#{$2[0,12]}"
"\n\n" "#{url}/commit/#{sha[0,10]}\n" }
} mod
print "[#{repo}] ", log end
subject = "[#{repo}] #{subject}"
subject.gsub!(/\s*\n\s*/, " ")
if conv[subject]
if subject.size > 68
subject.gsub!(/\G.{,67}[^\s.,][.,]*\K\s+/, "\n")
end
end
if log
conv[log]
log.sub!(/\s*(?=(?i:\nCo-authored-by:.*)*\Z)/) {
"\n\n" "#{url}/commit/#{sha[0,10]}\n"
}
end
print subject, "\n\n", log
end end
# NOTE: This method is also used by GitHub ruby/git.ruby-lang.org's bin/update-default-gem.sh # NOTE: This method is also used by GitHub ruby/git.ruby-lang.org's bin/update-default-gem.sh