Commit 1e1c5b7afe42d6d88997aaa4f4877c37965866a5

Authored by Valeriy Sizov
1 parent 279c4262

Diff refactoring

app/helpers/commits_helper.rb
@@ -17,7 +17,7 @@ module CommitsHelper @@ -17,7 +17,7 @@ module CommitsHelper
17 preserve out 17 preserve out
18 end 18 end
19 19
20 - def diff_line_class(line) 20 + def identification_type(line)
21 if line[0] == "+" 21 if line[0] == "+"
22 "new" 22 "new"
23 elsif line[0] == "-" 23 elsif line[0] == "-"
@@ -27,7 +27,7 @@ module CommitsHelper @@ -27,7 +27,7 @@ module CommitsHelper
27 end 27 end
28 end 28 end
29 29
30 - def build_line_code(line, index, line_new, line_old) 30 + def build_line_anchor(index, line_new, line_old)
31 "#{index}_#{line_old}_#{line_new}" 31 "#{index}_#{line_old}_#{line_new}"
32 end 32 end
33 33
@@ -51,12 +51,12 @@ module CommitsHelper @@ -51,12 +51,12 @@ module CommitsHelper
51 line_old = line.match(/\-[0-9]*/)[0].to_i.abs rescue 0 51 line_old = line.match(/\-[0-9]*/)[0].to_i.abs rescue 0
52 line_new = line.match(/\+[0-9]*/)[0].to_i.abs rescue 0 52 line_new = line.match(/\+[0-9]*/)[0].to_i.abs rescue 0
53 53
54 - next if line_old == 1 && line_new == 1 54 + next if line_old == 1 && line_new == 1 #top of file
55 yield(full_line, type, nil, nil, nil) 55 yield(full_line, type, nil, nil, nil)
56 next 56 next
57 else 57 else
58 - type = diff_line_class(line)  
59 - line_code = build_line_code(line, index, line_new, line_old) 58 + type = identification_type(line)
  59 + line_code = build_line_anchor(index, line_new, line_old)
60 yield(full_line, type, line_code, line_new, line_old) 60 yield(full_line, type, line_code, line_new, line_old)
61 end 61 end
62 62
app/views/commits/_text_file.html.haml
1 -- too_big = max_lines = diff.diff.lines.count > 1000 1 +- too_big = diff.diff.lines.count > 1000
2 - if too_big 2 - if too_big
3 %a.supp_diff_link Diff suppressed. Click to show 3 %a.supp_diff_link Diff suppressed. Click to show
4 4