From 82489f02429c14f945dbef787308d13adfa0018d Mon Sep 17 00:00:00 2001 From: Kazuhiro NISHIYAMA Date: Fri, 10 Jul 2020 19:27:11 +0900 Subject: Show messages around the line when replacing failed in format_changelog --- tool/lib/vcs.rb | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'tool') 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('') -- cgit v1.2.3