BigW Consortium Gitlab

Show additions/deletions stats on merge request diff

parent 8e05ee36
...@@ -21,6 +21,7 @@ v 8.1.0 (unreleased) ...@@ -21,6 +21,7 @@ v 8.1.0 (unreleased)
- Fix bug when removed file was not appearing in merge request diff - Fix bug when removed file was not appearing in merge request diff
- Note the original location of a moved project when notifying users of the move - Note the original location of a moved project when notifying users of the move
- Improve error message when merging fails - Improve error message when merging fails
- Show additions/deletions stats on merge request diff
v 8.0.3 v 8.0.3
- Fix URL shown in Slack notifications - Fix URL shown in Slack notifications
......
- if params[:view] == 'parallel' - if params[:view] == 'parallel'
- fluid_layout true - fluid_layout true
- diff_files = safe_diff_files(diffs)
.gray-content-block.second-block .gray-content-block.second-block
.inline-parallel-buttons .inline-parallel-buttons
.btn-group .btn-group
= inline_diff_btn = inline_diff_btn
= parallel_diff_btn = parallel_diff_btn
= render 'projects/diffs/stats', diffs: diffs - additions = diff_files.sum(&:added_lines)
- deletions = diff_files.sum(&:removed_lines)
- diff_files = safe_diff_files(diffs) = render 'projects/diffs/stats', diff_files: diff_files,
additions: additions, deletions: deletions
- if diff_files.count < diffs.size - if diff_files.count < diffs.size
= render 'projects/diffs/warning', diffs: diffs, shown_files_count: diff_files.count = render 'projects/diffs/warning', diffs: diffs, shown_files_count: diff_files.count
......
...@@ -2,37 +2,35 @@ ...@@ -2,37 +2,35 @@
.commit-stat-summary .commit-stat-summary
Showing Showing
= link_to '#', class: 'js-toggle-button' do = link_to '#', class: 'js-toggle-button' do
%strong #{pluralize(diffs.count, "changed file")} %strong #{pluralize(diff_files.count, "changed file")}
- if current_controller?(:commit) with
- unless @commit.has_zero_stats? %strong.cgreen #{additions} additions
with and
%strong.cgreen #{@commit.stats.additions} additions %strong.cred #{deletions} deletions
and
%strong.cred #{@commit.stats.deletions} deletions
.file-stats.js-toggle-content.hide .file-stats.js-toggle-content.hide
%ul %ul
- diffs.each_with_index do |diff, i| - diff_files.each_with_index do |diff_file, i|
%li %li
- if diff.deleted_file - if diff_file.deleted_file
%span.deleted-file %span.deleted-file
%a{href: "#diff-#{i}"} %a{href: "#diff-#{i}"}
%i.fa.fa-minus %i.fa.fa-minus
= diff.old_path = diff_file.old_path
- elsif diff.renamed_file - elsif diff_file.renamed_file
%span.renamed-file %span.renamed-file
%a{href: "#diff-#{i}"} %a{href: "#diff-#{i}"}
%i.fa.fa-minus %i.fa.fa-minus
= diff.old_path = diff_file.old_path
&rarr; &rarr;
= diff.new_path = diff_file.new_path
- elsif diff.new_file - elsif diff_file.new_file
%span.new-file %span.new-file
%a{href: "#diff-#{i}"} %a{href: "#diff-#{i}"}
%i.fa.fa-plus %i.fa.fa-plus
= diff.new_path = diff_file.new_path
- else - else
%span.edit-file %span.edit-file
%a{href: "#diff-#{i}"} %a{href: "#diff-#{i}"}
%i.fa.fa-adjust %i.fa.fa-adjust
= diff.new_path = diff_file.new_path
...@@ -44,6 +44,14 @@ module Gitlab ...@@ -44,6 +44,14 @@ module Gitlab
diff.old_path diff.old_path
end end
end end
def added_lines
diff_lines.select(&:added?).size
end
def removed_lines
diff_lines.select(&:removed?).size
end
end end
end end
end end
...@@ -7,6 +7,14 @@ module Gitlab ...@@ -7,6 +7,14 @@ module Gitlab
@text, @type, @index = text, type, index @text, @type, @index = text, type, index
@old_pos, @new_pos = old_pos, new_pos @old_pos, @new_pos = old_pos, new_pos
end end
def added?
type == 'new'
end
def removed?
type == 'old'
end
end end
end end
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