Commit 42ba6d04 authored by Saito's avatar Saito

refactor each_line detect to detect all diff file

parent c2cfc52e
%table
- line_old = 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|
- line = encode(line)
- next if line.match(/^--- \/dev\/null/)
- next if line.match(/^--- a/)
- next if line.match(/^\+\+\+ b/)
......@@ -18,7 +18,7 @@
= link_to raw(diff_line_class(line) == "new" ? " " : line_old), "#OLD#{index}-#{line_old}", :id => "OLD#{index}-#{line_old}"
%td.new_line
= link_to raw(diff_line_class(line) == "old" ? " " : line_new) , "#NEW#{index}-#{line_new}", :id => "NEW#{index}-#{line_new}"
%td.line_content{:class => diff_line_class(full_line)}= raw "#{full_line}  "
%td.line_content{:class => diff_line_class(full_line)}= raw "#{full_line}  "
- if line[0] == "+"
- line_new += 1
- elsif line[0] == "-"
......
......@@ -23,6 +23,8 @@ module Utils
string.force_encoding(cd.encoding)
end
string.encode("utf-8", :undef => :replace, :replace => "?", :invalid => :replace)
rescue
"Invalid code encoding"
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment