Commit c86553cd authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'refactor_compare' into 'master'

Refactor Compare logic

Updated gitlab_git to version 5.4.0.
Fixes MR diff download link in case of huge diff.
Fixes #1026
parents ddbb3c30 70df6055
...@@ -29,7 +29,7 @@ gem 'omniauth-github' ...@@ -29,7 +29,7 @@ gem 'omniauth-github'
# Extracting information from a git repository # Extracting information from a git repository
# Provide access to Gitlab::Git library # Provide access to Gitlab::Git library
gem "gitlab_git", '~> 5.3.0' gem "gitlab_git", '~> 5.4.0'
# Ruby/Rack Git Smart-HTTP Server Handler # Ruby/Rack Git Smart-HTTP Server Handler
gem 'gitlab-grack', '~> 2.0.0.pre', require: 'grack' gem 'gitlab-grack', '~> 2.0.0.pre', require: 'grack'
......
...@@ -177,7 +177,7 @@ GEM ...@@ -177,7 +177,7 @@ GEM
charlock_holmes (~> 0.6.6) charlock_holmes (~> 0.6.6)
escape_utils (~> 0.2.4) escape_utils (~> 0.2.4)
mime-types (~> 1.19) mime-types (~> 1.19)
gitlab_git (5.3.0) gitlab_git (5.4.0)
activesupport (~> 4.0.0) activesupport (~> 4.0.0)
charlock_holmes (~> 0.6.9) charlock_holmes (~> 0.6.9)
gitlab-grit (~> 2.6.1) gitlab-grit (~> 2.6.1)
...@@ -579,7 +579,7 @@ DEPENDENCIES ...@@ -579,7 +579,7 @@ DEPENDENCIES
gitlab-gollum-lib (~> 1.1.0) gitlab-gollum-lib (~> 1.1.0)
gitlab-grack (~> 2.0.0.pre) gitlab-grack (~> 2.0.0.pre)
gitlab-linguist (~> 3.0.0) gitlab-linguist (~> 3.0.0)
gitlab_git (~> 5.3.0) gitlab_git (~> 5.4.0)
gitlab_meta (= 6.0) gitlab_meta (= 6.0)
gitlab_omniauth-ldap (= 1.0.4) gitlab_omniauth-ldap (= 1.0.4)
gon (~> 5.0.0) gon (~> 5.0.0)
......
...@@ -15,11 +15,7 @@ class Projects::CompareController < Projects::ApplicationController ...@@ -15,11 +15,7 @@ class Projects::CompareController < Projects::ApplicationController
@diffs = compare.diffs @diffs = compare.diffs
@refs_are_same = compare.same @refs_are_same = compare.same
@line_notes = [] @line_notes = []
@timeout = compare.timeout
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]
......
...@@ -17,6 +17,7 @@ module Emails ...@@ -17,6 +17,7 @@ module Emails
def repository_push_email(project_id, recipient, author_id, branch, compare) def repository_push_email(project_id, recipient, author_id, branch, compare)
@project = Project.find(project_id) @project = Project.find(project_id)
@author = User.find(author_id) @author = User.find(author_id)
@compare = compare
@commits = Commit.decorate(compare.commits) @commits = Commit.decorate(compare.commits)
@diffs = compare.diffs @diffs = compare.diffs
@branch = branch @branch = branch
......
...@@ -148,13 +148,11 @@ class MergeRequestDiff < ActiveRecord::Base ...@@ -148,13 +148,11 @@ class MergeRequestDiff < ActiveRecord::Base
Gitlab::Git::Diff.between(repository, source_branch, target_branch) Gitlab::Git::Diff.between(repository, source_branch, target_branch)
end end
if diffs == broken_diffs
self.state = :timeout
diffs = []
end
diffs ||= [] diffs ||= []
diffs diffs
rescue Gitlab::Git::Diff::TimeoutError => ex
self.state = :timeout
diffs = []
end end
def repository def repository
......
...@@ -21,3 +21,8 @@ ...@@ -21,3 +21,8 @@
%pre %pre
= diff.diff = diff.diff
%br %br
- if @compare.timeout
%h5 Huge diff. To prevent performance issues it was hidden
- elsif @compare.commits_over_limit?
%h5 Diff for big amount of commits is disabled
...@@ -18,3 +18,8 @@ Diff: ...@@ -18,3 +18,8 @@ Diff:
= diff.new_path || diff.old_path = diff.new_path || diff.old_path
\===================================== \=====================================
= diff.diff = diff.diff
\
- if @compare.timeout
Huge diff. To prevent performance issues it was hidden
- elsif @compare.commits_over_limit?
Diff for big amount of commits is disabled
...@@ -3,8 +3,10 @@ ...@@ -3,8 +3,10 @@
- elsif @merge_request_diff.empty? - elsif @merge_request_diff.empty?
%h4.nothing_here_message Nothing to merge from #{@merge_request.source_branch} into #{@merge_request.target_branch} %h4.nothing_here_message Nothing to merge from #{@merge_request.source_branch} into #{@merge_request.target_branch}
- else - else
%h4.nothing_here_message .bs-callout.bs-callout-warning
Can't load diff. %h4
Diff for this comparison is extremely large.
%p
You can You can
= link_to "download it", project_merge_request_path(@merge_request.source_project, @merge_request), format: :diff, class: "vlink" = link_to "download it", project_merge_request_path(@merge_request.source_project, @merge_request, format: :diff), class: "vlink"
instead. instead.
...@@ -13,13 +13,13 @@ class EmailsOnPushWorker ...@@ -13,13 +13,13 @@ class EmailsOnPushWorker
return true return true
end end
compare = Gitlab::Git::Compare.new(project.repository.raw_repository, before_sha, after_sha) compare = Gitlab::Git::Compare.new(project.repository.raw_repository, before_sha, after_sha, MergeRequestDiff::COMMITS_SAFE_SIZE)
# Do not send emails if git compare failed # Do not send emails if git compare failed
return false unless compare && compare.commits.present? return false unless compare && compare.commits.present?
recipients.split(" ").each do |recipient| recipients.split(" ").each do |recipient|
Notify.delay.repository_push_email(project_id, recipient, author_id, branch, compare) Notify.repository_push_email(project_id, recipient, author_id, branch, compare).deliver
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