diff options
author | Kazuhiro NISHIYAMA <zn@mbf.nifty.com> | 2020-07-10 19:27:11 +0900 |
---|---|---|
committer | Kazuhiro NISHIYAMA <zn@mbf.nifty.com> | 2020-07-10 19:27:11 +0900 |
commit | 82489f02429c14f945dbef787308d13adfa0018d (patch) | |
tree | 83fd9540e2d50f59e2f979dc73c99b9eb966faf1 | |
parent | 615758bd823d52e542976bbc83a728c1bad28ade (diff) |
Show messages around the line when replacing failed in format_changelog
-rw-r--r-- | tool/lib/vcs.rb | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/tool/lib/vcs.rb b/tool/lib/vcs.rb index 2f9ba46e55..0c01abb0ac 100644 --- a/tool/lib/vcs.rb +++ b/tool/lib/vcs.rb @@ -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('') |