summaryrefslogtreecommitdiff
path: root/tool
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2022-10-18 12:13:06 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2022-10-18 17:43:43 +0900
commite1ca90c2a4e392073480e7c0b4bed0b9948fad94 (patch)
tree9be9ffce857b4ead167ccd72ebdb44b2df8ec09c /tool
parent93d73cfe80455e74d7853df443dcdf5d2157cadf (diff)
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.
Diffstat (limited to 'tool')
-rwxr-xr-xtool/sync_default_gems.rb34
1 files changed, 24 insertions, 10 deletions
diff --git a/tool/sync_default_gems.rb b/tool/sync_default_gems.rb
index 9fcbeb7d22..d7151af701 100755
--- a/tool/sync_default_gems.rb
+++ b/tool/sync_default_gems.rb
@@ -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+\))/) {
- "#{url}/pull/"
- }
- log.gsub!(%r{(?<![-\[\](){}\w@/])(?:(\w+(?:-\w+)*/\w+(?:-\w+)*)@)?(\h{10,40})\b}) {|c|
- "https://github.com/#{$1 || repo}/commit/#{$2[0,12]}"
- }
- log.sub!(/\s*(?=(?i:\nCo-authored-by:.*)*\Z)/) {
- "\n\n" "#{url}/commit/#{sha[0,10]}\n"
- }
- print "[#{repo}] ", log
+ 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/"
+ }
+ 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"
+ }
+ 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