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's avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 70fe671c
Pipeline #4041652 passed with stages
in 41 minutes and 17 seconds
......@@ -65,13 +65,6 @@ class MergeRequestDiff < ActiveRecord::Base
start_commit_sha || merge_request.target_branch_sha
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
real_size.presence || raw_diffs.size
end
......@@ -82,7 +75,7 @@ class MergeRequestDiff < ActiveRecord::Base
Gitlab::Git::Compare.new(
repository.raw_repository,
safe_start_commit_sha,
safe_head_commit_sha).diffs(options)
head_commit_sha).diffs(options)
else
@raw_diffs ||= {}
@raw_diffs[options] ||= load_diffs(st_diffs, options)
......@@ -148,16 +141,11 @@ class MergeRequestDiff < ActiveRecord::Base
def compare
@compare ||=
begin
# Update ref for merge request
merge_request.fetch_ref
Gitlab::Git::Compare.new(
repository.raw_repository,
safe_start_commit_sha,
safe_head_commit_sha
)
end
Gitlab::Git::Compare.new(
repository.raw_repository,
safe_start_commit_sha,
head_commit_sha
)
end
def latest?
......
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