Restore diff_sha_refs method
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
parent
9329436deb
commit
eb355dec87
|
@ -118,8 +118,12 @@ class DiffNote < Note
|
|||
end
|
||||
|
||||
def noteable_diff_refs
|
||||
if noteable.respond_to?(:diff_sha_refs)
|
||||
noteable.diff_sha_refs
|
||||
else
|
||||
noteable.diff_refs
|
||||
end
|
||||
end
|
||||
|
||||
def set_original_position
|
||||
self.original_position = self.position.dup
|
||||
|
|
|
@ -265,26 +265,27 @@ class MergeRequest < ActiveRecord::Base
|
|||
@source_branch_sha || source_branch_head.try(:sha)
|
||||
end
|
||||
|
||||
def branch_merge_base_sha
|
||||
branch_merge_base_commit.try(:sha)
|
||||
def diff_refs
|
||||
return unless diff_start_commit || diff_base_commit
|
||||
|
||||
Gitlab::Diff::DiffRefs.new(
|
||||
base_sha: diff_base_sha,
|
||||
start_sha: diff_start_sha,
|
||||
head_sha: diff_head_sha
|
||||
)
|
||||
end
|
||||
|
||||
def diff_refs
|
||||
# Return diff_refs instance trying to not touch the git repository
|
||||
def diff_sha_refs
|
||||
if merge_request_diff && merge_request_diff.diff_refs_by_sha?
|
||||
merge_request_diff.diff_refs
|
||||
else
|
||||
start_sha = target_branch_sha
|
||||
head_sha = source_branch_sha
|
||||
base_sha = branch_merge_base_sha
|
||||
diff_refs
|
||||
end
|
||||
end
|
||||
|
||||
if start_sha || base_sha
|
||||
Gitlab::Diff::DiffRefs.new(
|
||||
base_sha: base_sha,
|
||||
start_sha: start_sha,
|
||||
head_sha: head_sha
|
||||
)
|
||||
end
|
||||
end
|
||||
def branch_merge_base_sha
|
||||
branch_merge_base_commit.try(:sha)
|
||||
end
|
||||
|
||||
def validate_branches
|
||||
|
@ -748,7 +749,7 @@ class MergeRequest < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def has_complete_diff_refs?
|
||||
diff_refs && diff_refs.complete?
|
||||
diff_sha_refs && diff_sha_refs.complete?
|
||||
end
|
||||
|
||||
def update_diff_notes_positions(old_diff_refs:, new_diff_refs:)
|
||||
|
|
|
@ -782,7 +782,7 @@ describe MergeRequest, models: true do
|
|||
end
|
||||
end
|
||||
|
||||
describe "#diff_refs" do
|
||||
describe "#diff_sha_refs" do
|
||||
context "with diffs" do
|
||||
subject { create(:merge_request, :with_diffs) }
|
||||
|
||||
|
@ -791,7 +791,7 @@ describe MergeRequest, models: true do
|
|||
|
||||
expect_any_instance_of(Repository).not_to receive(:commit)
|
||||
|
||||
subject.diff_refs
|
||||
subject.diff_sha_refs
|
||||
end
|
||||
|
||||
it "returns expected diff_refs" do
|
||||
|
@ -801,7 +801,7 @@ describe MergeRequest, models: true do
|
|||
head_sha: subject.merge_request_diff.head_commit_sha
|
||||
)
|
||||
|
||||
expect(subject.diff_refs).to eq(expected_diff_refs)
|
||||
expect(subject.diff_sha_refs).to eq(expected_diff_refs)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue