Commit a943ccf1 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Change the way merge request diff compare works

* remove ref fetch (we do it during creation anyway)
* remove safe_head_commit_sha for diff compare (do not depend on the source branch)
Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 70fe671c
...@@ -65,13 +65,6 @@ class MergeRequestDiff < ActiveRecord::Base ...@@ -65,13 +65,6 @@ class MergeRequestDiff < ActiveRecord::Base
start_commit_sha || merge_request.target_branch_sha start_commit_sha || merge_request.target_branch_sha
end end
# This method will rely on repository branch sha
# in case head_commit_sha is nil. Its necesarry for old merge request diff
# created before version 8.4 to work
def safe_head_commit_sha
head_commit_sha || merge_request.source_branch_sha
end
def size def size
real_size.presence || raw_diffs.size real_size.presence || raw_diffs.size
end end
...@@ -82,7 +75,7 @@ class MergeRequestDiff < ActiveRecord::Base ...@@ -82,7 +75,7 @@ class MergeRequestDiff < ActiveRecord::Base
Gitlab::Git::Compare.new( Gitlab::Git::Compare.new(
repository.raw_repository, repository.raw_repository,
safe_start_commit_sha, safe_start_commit_sha,
safe_head_commit_sha).diffs(options) head_commit_sha).diffs(options)
else else
@raw_diffs ||= {} @raw_diffs ||= {}
@raw_diffs[options] ||= load_diffs(st_diffs, options) @raw_diffs[options] ||= load_diffs(st_diffs, options)
...@@ -148,17 +141,12 @@ class MergeRequestDiff < ActiveRecord::Base ...@@ -148,17 +141,12 @@ class MergeRequestDiff < ActiveRecord::Base
def compare def compare
@compare ||= @compare ||=
begin
# Update ref for merge request
merge_request.fetch_ref
Gitlab::Git::Compare.new( Gitlab::Git::Compare.new(
repository.raw_repository, repository.raw_repository,
safe_start_commit_sha, safe_start_commit_sha,
safe_head_commit_sha head_commit_sha
) )
end end
end
def latest? def latest?
self == merge_request.merge_request_diff self == merge_request.merge_request_diff
......
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