Commit f7d30c20 authored by Sean McGivern's avatar Sean McGivern
Browse files

Merge branch 'fix-merge-request-screen-deleted-source-branch' into 'master'

Do not create a MergeRequestDiff record when source branch is deleted

Fixes #23413 
Fixes #23897

See merge request !7481
......@@ -60,15 +60,7 @@ def reload_merge_requests
merge_requests = filter_merge_requests(merge_requests)
merge_requests.each do |merge_request|
if merge_request.source_branch == @branch_name || force_push?
merge_request.reload_diff
else
mr_commit_ids = merge_request.commits.map(&:id)
push_commit_ids = @commits.map(&:id)
matches = mr_commit_ids & push_commit_ids
merge_request.reload_diff if matches.any?
end
reload_diff(merge_request) unless branch_removed?
merge_request.mark_as_unchecked
end
end
......@@ -173,5 +165,16 @@ def branch_added?
def branch_removed?
Gitlab::Git.blank_ref?(@newrev)
end
def reload_diff(merge_request)
if merge_request.source_branch == @branch_name || force_push?
merge_request.reload_diff
else
mr_commit_ids = merge_request.commits.map(&:id)
push_commit_ids = @commits.map(&:id)
matches = mr_commit_ids & push_commit_ids
merge_request.reload_diff if matches.any?
end
end
end
end
---
title: Do not create a MergeRequestDiff record when source branch is deleted
merge_request: 7481
author:
......@@ -227,6 +227,16 @@
end
end
context 'when the source branch is deleted' do
it 'does not create a MergeRequestDiff record' do
refresh_service = service.new(@project, @user)
expect do
refresh_service.execute(@oldrev, Gitlab::Git::BLANK_SHA, 'refs/heads/master')
end.not_to change { MergeRequestDiff.count }
end
end
def reload_mrs
@merge_request.reload
@fork_merge_request.reload
......
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