aboutsummaryrefslogtreecommitdiffstats
path: root/tool/lib/vcs.rb
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2021-09-03 23:46:33 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2021-09-03 23:46:33 +0900
commitaf68112a1b8512c8d5c9823f0f71db8df1c0c6b1 (patch)
tree1be3fb07e2b33e35cf3cee11ae0ffacf97b2318a /tool/lib/vcs.rb
parentc60a52954378a0e28ab0c05718c81a2bb1aeb7c6 (diff)
downloadruby-af68112a1b8512c8d5c9823f0f71db8df1c0c6b1.tar.gz
Add some punctuations as regexp separators to fix commit logs
Diffstat (limited to 'tool/lib/vcs.rb')
-rw-r--r--tool/lib/vcs.rb19
1 files changed, 12 insertions, 7 deletions
diff --git a/tool/lib/vcs.rb b/tool/lib/vcs.rb
index 5d78d94c26..1ccf80a49f 100644
--- a/tool/lib/vcs.rb
+++ b/tool/lib/vcs.rb
@@ -575,6 +575,8 @@ class VCS
end
end
+ LOG_FIX_REGEXP_SEPARATORS = '/!:;|,#%&'
+
def format_changelog(path, arg, base_url = nil)
env = {'TZ' => 'JST-9', 'LANG' => 'C', 'LC_ALL' => 'C'}
cmd = %W"#{COMMAND} log --format=fuller --notes=commits --notes=log-fix --topo-order --no-merges"
@@ -596,13 +598,16 @@ class VCS
s = s.lines
fix.each_line do |x|
case x
- when %r[^ +(\d+)s/(.+)/(.*)/]
+ when %r[^ +(\d+)s([#{LOG_FIX_REGEXP_SEPARATORS}])(.+)\2(.*)\2]o
+ n = $1.to_i
+ wrong = $3
+ correct = $4
begin
- s[$1.to_i][$2] = $3
+ s[n][wrong] = correct
rescue IndexError
- message = ["format_changelog failed to replace #{$2.dump} with #{$3.dump} at #$1\n"]
- from = [1, $1.to_i-2].max
- to = [s.size-1, $1.to_i+2].min
+ message = ["format_changelog failed to replace #{wrong.dump} with #{correct.dump} at #$1\n"]
+ from = [1, n-2].max
+ to = [s.size-1, n+2].min
s.each_with_index do |e, i|
next if i < from
break if to < i
@@ -610,8 +615,8 @@ class VCS
end
raise message.join('')
end
- when %r[^( +)(\d+)i/(.*)/]
- s[$2.to_i, 0] = "#{$1}#{$3}\n"
+ when %r[^( +)(\d+)i([#{LOG_FIX_REGEXP_SEPARATORS}])(.*)\3]o
+ s[$2.to_i, 0] = "#{$1}#{$4}\n"
when %r[^ +(\d+)(?:,(\d+))?d]
n = $1.to_i
e = $2