Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgitlabhq <m@gitlabhq.com>2011-10-21 22:40:36 +0400
committergitlabhq <m@gitlabhq.com>2011-10-22 15:08:03 +0400
commit1a9531c9a42e380d922de98ad1658e85ac5fbde6 (patch)
tree37c77036ac3877068e26b94beda075c2f41de9dc /app/views/commits
parent29e11d1461a5689ff295adb035e38564701ad377 (diff)
fix #140, commit lil refactor
Diffstat (limited to 'app/views/commits')
-rw-r--r--app/views/commits/_diff.html.haml41
-rw-r--r--app/views/commits/_diff_head.html.haml24
-rw-r--r--app/views/commits/_text_file.html.haml15
3 files changed, 42 insertions, 38 deletions
diff --git a/app/views/commits/_diff.html.haml b/app/views/commits/_diff.html.haml
index c88e54307e9..2807e0903da 100644
--- a/app/views/commits/_diff.html.haml
+++ b/app/views/commits/_diff.html.haml
@@ -1,27 +1,5 @@
-.file_stats
- - @commit.diffs.each do |diff|
- - if diff.deleted_file
- %span.removed_file
- %a{:href => "##{diff.a_path}"}
- = diff.a_path
- = image_tag "blueprint_delete.png"
- - elsif diff.renamed_file
- %span.moved_file
- %a{:href => "##{diff.b_path}"}
- = diff.a_path
- = "->"
- = diff.b_path
- = image_tag "blueprint_notice.png"
- - elsif diff.new_file
- %span.new_file
- %a{:href => "##{diff.b_path}"}
- = diff.b_path
- = image_tag "blueprint_add.png"
- - else
- %span.edit_file
- %a{:href => "##{diff.b_path}"}
- = diff.b_path
- = image_tag "blueprint_info.png"
+.file_stats= render "commits/diff_head"
+
- @commit.diffs.each do |diff|
- next if diff.diff.empty?
- file = (@commit.tree / diff.b_path)
@@ -36,20 +14,7 @@
%br/
.diff_file_content
- if file.text?
- - lines_arr = diff.diff.lines.to_a
- - line_old = lines_arr[2].match(/-(\d)/)[0].to_i.abs rescue 0
- - line_new = lines_arr[2].match(/\+(\d)/)[0].to_i.abs rescue 0
- - lines = lines_arr[3..-1].join
- - lines.each_line do |line|
- = diff_line(line, line_new, line_old)
- - if line[0] == "+"
- - line_new += 1
- - elsif
- - line[0] == "-"
- - line_old += 1
- - else
- - line_new += 1
- - line_old += 1
+ = render :partial => "commits/text_file", :locals => { :diff => diff }
- elsif file.image?
.diff_file_content_image
%img{:src => "data:#{file.mime_type};base64,#{Base64.encode64(file.data)}"}
diff --git a/app/views/commits/_diff_head.html.haml b/app/views/commits/_diff_head.html.haml
new file mode 100644
index 00000000000..922c35990af
--- /dev/null
+++ b/app/views/commits/_diff_head.html.haml
@@ -0,0 +1,24 @@
+- @commit.diffs.each do |diff|
+ - if diff.deleted_file
+ %span.removed_file
+ %a{:href => "##{diff.a_path}"}
+ = diff.a_path
+ = image_tag "blueprint_delete.png"
+ - elsif diff.renamed_file
+ %span.moved_file
+ %a{:href => "##{diff.b_path}"}
+ = diff.a_path
+ = "->"
+ = diff.b_path
+ = image_tag "blueprint_notice.png"
+ - elsif diff.new_file
+ %span.new_file
+ %a{:href => "##{diff.b_path}"}
+ = diff.b_path
+ = image_tag "blueprint_add.png"
+ - else
+ %span.edit_file
+ %a{:href => "##{diff.b_path}"}
+ = diff.b_path
+ = image_tag "blueprint_info.png"
+
diff --git a/app/views/commits/_text_file.html.haml b/app/views/commits/_text_file.html.haml
new file mode 100644
index 00000000000..b20aa8afe40
--- /dev/null
+++ b/app/views/commits/_text_file.html.haml
@@ -0,0 +1,15 @@
+- lines_arr = diff.diff.lines.to_a
+- line_old = lines_arr[2].match(/-(\d)/)[0].to_i.abs rescue 0
+- line_new = lines_arr[2].match(/\+(\d)/)[0].to_i.abs rescue 0
+- lines = lines_arr[3..-1].join
+- lines.each_line do |line|
+ = diff_line(line, line_new, line_old)
+ - if line[0] == "+"
+ - line_new += 1
+ - elsif
+ - line[0] == "-"
+ - line_old += 1
+ - else
+ - line_new += 1
+ - line_old += 1
+