refactor each_line detect to detect all diff file
This commit is contained in:
parent
c2cfc52e44
commit
42ba6d04f8
2 changed files with 5 additions and 3 deletions
|
@ -1,9 +1,9 @@
|
||||||
%table
|
%table
|
||||||
- line_old = 0
|
- line_old = 0
|
||||||
- line_new = 0
|
- line_new = 0
|
||||||
- lines_arr = diff.diff.lines.to_a
|
- diff_str = encode(diff.diff)
|
||||||
|
- lines_arr = diff_str.lines.to_a
|
||||||
- lines_arr.each do |line|
|
- lines_arr.each do |line|
|
||||||
- line = encode(line)
|
|
||||||
- next if line.match(/^--- \/dev\/null/)
|
- next if line.match(/^--- \/dev\/null/)
|
||||||
- next if line.match(/^--- a/)
|
- next if line.match(/^--- a/)
|
||||||
- next if line.match(/^\+\+\+ b/)
|
- next if line.match(/^\+\+\+ b/)
|
||||||
|
|
|
@ -23,6 +23,8 @@ module Utils
|
||||||
string.force_encoding(cd.encoding)
|
string.force_encoding(cd.encoding)
|
||||||
end
|
end
|
||||||
string.encode("utf-8", :undef => :replace, :replace => "?", :invalid => :replace)
|
string.encode("utf-8", :undef => :replace, :replace => "?", :invalid => :replace)
|
||||||
|
rescue
|
||||||
|
"Invalid code encoding"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue