1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Show messages around the line when replacing failed in format_changelog

This commit is contained in:
Kazuhiro NISHIYAMA 2020-07-10 19:27:11 +09:00
parent 615758bd82
commit 82489f0242
No known key found for this signature in database
GPG key ID: 262ED8DBB4222F7A

View file

@ -580,7 +580,19 @@ class VCS
s = s.lines
fix.each_line do |x|
if %r[^ +(\d+)s/(.+)/(.*)/] =~ x
s[$1.to_i][$2] = $3
begin
s[$1.to_i][$2] = $3
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
s.each_with_index do |e, i|
next if i < from
break if to < i
message << "#{i}:#{e}"
end
raise message.join('')
end
end
end
s = s.join('')