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: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
Dmitriy Zaporozhets 2016-08-25 11:58:17 +03:00
parent 70fe671c29
commit a943ccf10e
No known key found for this signature in database
GPG key ID: 627C5F589F467F17

View file

@ -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
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
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