Diff refactoring
This commit is contained in:
parent
279c4262f9
commit
1e1c5b7afe
|
@ -17,7 +17,7 @@ module CommitsHelper
|
||||||
preserve out
|
preserve out
|
||||||
end
|
end
|
||||||
|
|
||||||
def diff_line_class(line)
|
def identification_type(line)
|
||||||
if line[0] == "+"
|
if line[0] == "+"
|
||||||
"new"
|
"new"
|
||||||
elsif line[0] == "-"
|
elsif line[0] == "-"
|
||||||
|
@ -27,7 +27,7 @@ module CommitsHelper
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def build_line_code(line, index, line_new, line_old)
|
def build_line_anchor(index, line_new, line_old)
|
||||||
"#{index}_#{line_old}_#{line_new}"
|
"#{index}_#{line_old}_#{line_new}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -51,12 +51,12 @@ module CommitsHelper
|
||||||
line_old = line.match(/\-[0-9]*/)[0].to_i.abs rescue 0
|
line_old = line.match(/\-[0-9]*/)[0].to_i.abs rescue 0
|
||||||
line_new = line.match(/\+[0-9]*/)[0].to_i.abs rescue 0
|
line_new = line.match(/\+[0-9]*/)[0].to_i.abs rescue 0
|
||||||
|
|
||||||
next if line_old == 1 && line_new == 1
|
next if line_old == 1 && line_new == 1 #top of file
|
||||||
yield(full_line, type, nil, nil, nil)
|
yield(full_line, type, nil, nil, nil)
|
||||||
next
|
next
|
||||||
else
|
else
|
||||||
type = diff_line_class(line)
|
type = identification_type(line)
|
||||||
line_code = build_line_code(line, index, line_new, line_old)
|
line_code = build_line_anchor(index, line_new, line_old)
|
||||||
yield(full_line, type, line_code, line_new, line_old)
|
yield(full_line, type, line_code, line_new, line_old)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
- too_big = max_lines = diff.diff.lines.count > 1000
|
- too_big = diff.diff.lines.count > 1000
|
||||||
- if too_big
|
- if too_big
|
||||||
%a.supp_diff_link Diff suppressed. Click to show
|
%a.supp_diff_link Diff suppressed. Click to show
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue