Improve VCS::GIT#format_changelog addessing [ci skip]
This commit is contained in:
parent
1da97292f8
commit
d80002c902
@ -698,15 +698,22 @@ class VCS
|
|||||||
fix = $1
|
fix = $1
|
||||||
s = s.lines
|
s = s.lines
|
||||||
fix.each_line do |x|
|
fix.each_line do |x|
|
||||||
|
next unless x.sub!(/^(\s+)(?:(\d+)|\$(?:-\d+)?)/, '')
|
||||||
|
b = ($2&.to_i || (s.size - 1 + $3.to_i))
|
||||||
|
sp = $1
|
||||||
|
if x.sub!(/^,(?:(\d+)|\$(?:-\d+)?)/, '')
|
||||||
|
range = b..($1&.to_i || (s.size - 1 + $2.to_i))
|
||||||
|
else
|
||||||
|
range = b..b
|
||||||
|
end
|
||||||
case x
|
case x
|
||||||
when %r[^ +(\d+)s([#{LOG_FIX_REGEXP_SEPARATORS}])(.+)\2(.*)\2]o
|
when %r[^s([#{LOG_FIX_REGEXP_SEPARATORS}])(.+)\1(.*)\1]o
|
||||||
n = $1.to_i
|
wrong = $2
|
||||||
wrong = $3
|
correct = $3
|
||||||
correct = $4
|
range.each do |n|
|
||||||
begin
|
|
||||||
s[n][wrong] = correct
|
s[n][wrong] = correct
|
||||||
rescue IndexError
|
rescue IndexError
|
||||||
message = ["format_changelog failed to replace #{wrong.dump} with #{correct.dump} at #$1\n"]
|
message = ["format_changelog failed to replace #{wrong.dump} with #{correct.dump} at #{n}\n"]
|
||||||
from = [1, n-2].max
|
from = [1, n-2].max
|
||||||
to = [s.size-1, n+2].min
|
to = [s.size-1, n+2].min
|
||||||
s.each_with_index do |e, i|
|
s.each_with_index do |e, i|
|
||||||
@ -716,12 +723,13 @@ class VCS
|
|||||||
end
|
end
|
||||||
raise message.join('')
|
raise message.join('')
|
||||||
end
|
end
|
||||||
when %r[^( +)(\d+)i([#{LOG_FIX_REGEXP_SEPARATORS}])(.*)\3]o
|
when %r[^i([#{LOG_FIX_REGEXP_SEPARATORS}])(.*)\1]o
|
||||||
s[$2.to_i, 0] = "#{$1}#{$4}\n"
|
insert = "#{sp}#{$2}\n"
|
||||||
when %r[^ +(\d+)(?:,(\d+))?d]
|
range.reverse_each do |n|
|
||||||
n = $1.to_i
|
s[n, 0] = insert
|
||||||
e = $2
|
end
|
||||||
s[n..(e ? e.to_i : n)] = []
|
when %r[^d]
|
||||||
|
s[range] = []
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
s = s.join('')
|
s = s.join('')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user