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: 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.delete!("\r")
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)
conv = proc do |s|
mod = true if s.gsub!(/\b(?:(?i:fix(?:e[sd])?) +)\K#(?=\d+\b)|\bGH-#?(?=\d+\b)|\(\K#(?=\d+\))/) {
"#{url}/pull/"
}
log.gsub!(%r{(?<![-\[\](){}\w@/])(?:(\w+(?:-\w+)*/\w+(?:-\w+)*)@)?(\h{10,40})\b}) {|c|
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]}"
}
mod
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"
}
print "[#{repo}] ", log
end
print subject, "\n\n", log
end
# NOTE: This method is also used by GitHub ruby/git.ruby-lang.org's bin/update-default-gem.sh