Commit ea2a57cd authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'improve/compare_page' into 'master'

Improve Compare page

Prevent Compare page timout for large amount of commits.
Fixes #989
parents 2b592f29 a1a01254
v 6.6.0 v 6.6.0
- Permissions: Developer now can manage issue tracker (modify any issue) - Permissions: Developer now can manage issue tracker (modify any issue)
- Improve Code Compare page performance
v 6.5.1 v 6.5.1
- Fix branch selectbox when create merge request from fork - Fix branch selectbox when create merge request from fork
......
...@@ -23,6 +23,12 @@ ...@@ -23,6 +23,12 @@
} }
} }
&.warning-row {
background-color: #fcf8e3;
border-color: #faebcc;
color: #8a6d3b;
}
&.smoke { background-color: #f5f5f5; } &.smoke { background-color: #f5f5f5; }
&:hover { &:hover {
......
...@@ -8,7 +8,7 @@ class Projects::CompareController < Projects::ApplicationController ...@@ -8,7 +8,7 @@ class Projects::CompareController < Projects::ApplicationController
end end
def show def show
compare = Gitlab::Git::Compare.new(@repository.raw_repository, params[:from], params[:to]) compare = Gitlab::Git::Compare.new(@repository.raw_repository, params[:from], params[:to], MergeRequestDiff::COMMITS_SAFE_SIZE)
@commits = compare.commits @commits = compare.commits
@commit = compare.commit @commit = compare.commit
...@@ -16,6 +16,11 @@ class Projects::CompareController < Projects::ApplicationController ...@@ -16,6 +16,11 @@ class Projects::CompareController < Projects::ApplicationController
@refs_are_same = compare.same @refs_are_same = compare.same
@line_notes = [] @line_notes = []
if @diffs == [Gitlab::Git::Diff::BROKEN_DIFF]
@diffs = []
@timeout = true
end
diff_line_count = Commit::diff_line_count(@diffs) diff_line_count = Commit::diff_line_count(@diffs)
@suppress_diff = Commit::diff_suppress?(@diffs, diff_line_count) && !params[:force_show_diff] @suppress_diff = Commit::diff_suppress?(@diffs, diff_line_count) && !params[:force_show_diff]
@force_suppress_diff = Commit::diff_force_suppress?(@diffs, diff_line_count) @force_suppress_diff = Commit::diff_force_suppress?(@diffs, diff_line_count)
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
&nbsp; &nbsp;
= submit_tag "Compare", class: "btn btn-create commits-compare-btn" = submit_tag "Compare", class: "btn btn-create commits-compare-btn"
- if compare_to_mr_button? - if compare_to_mr_button?
= link_to compare_mr_path, class: 'prepend-left-10' do = link_to compare_mr_path, class: 'prepend-left-10 btn' do
%strong Make a merge request %strong Make a merge request
......
...@@ -5,21 +5,32 @@ ...@@ -5,21 +5,32 @@
= render "form" = render "form"
- if @commits.size > 100
.alert.alert-warning
%p
%strong Warning! This comparison includes more than 100 commits.
%p To preserve performance the line diff is not shown.
- if @commits.present? - if @commits.present?
%div.ui-box %div.ui-box
.title .title
Commits (#{@commits.count}) Commits (#{@commits.count})
%ul.well-list= render Commit.decorate(@commits), project: @project - if @commits.size > MergeRequestDiff::COMMITS_SAFE_SIZE
%ul.well-list
- Commit.decorate(@commits.first(MergeRequestDiff::COMMITS_SAFE_SIZE)).each do |commit|
= render "projects/commits/inline_commit", commit: commit, project: @project
%li.warning-row.unstyled
other #{@commits.size - MergeRequestDiff::COMMITS_SAFE_SIZE} commits hidden to prevent performance issues.
- else
%ul.well-list= render Commit.decorate(@commits), project: @project
- unless @diffs.empty? %h4 Diff
%h4 Diff - if @diffs.present?
= render "projects/commits/diffs", diffs: @diffs, project: @project = render "projects/commits/diffs", diffs: @diffs, project: @project
- elsif @commits.size > MergeRequestDiff::COMMITS_SAFE_SIZE
.bs-callout.bs-callout-danger
%h4 This comparison includes more than #{MergeRequestDiff::COMMITS_SAFE_SIZE} commits.
%p To preserve performance the line diff is not shown.
- elsif @timeout
.bs-callout.bs-callout-danger
%h4 Diff for this comparison is extremely large.
%p Use command line to browse diff for this comparison.
- else - else
.light-well .light-well
%center %center
......
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