Commit 9e9965ba authored by Adam Niedzielski's avatar Adam Niedzielski

Revert "Do not create a MergeRequestDiff record when source branch is deleted"

This reverts commit f913170e.
parent 5018bdcd
...@@ -60,7 +60,15 @@ module MergeRequests ...@@ -60,7 +60,15 @@ module MergeRequests
merge_requests = filter_merge_requests(merge_requests) merge_requests = filter_merge_requests(merge_requests)
merge_requests.each do |merge_request| merge_requests.each do |merge_request|
reload_diff(merge_request) unless branch_removed? 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
merge_request.mark_as_unchecked merge_request.mark_as_unchecked
end end
end end
...@@ -165,16 +173,5 @@ module MergeRequests ...@@ -165,16 +173,5 @@ module MergeRequests
def branch_removed? def branch_removed?
Gitlab::Git.blank_ref?(@newrev) Gitlab::Git.blank_ref?(@newrev)
end 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
end end
---
title: Do not create a MergeRequestDiff record when source branch is deleted
merge_request: 7481
author:
...@@ -227,16 +227,6 @@ describe MergeRequests::RefreshService, services: true do ...@@ -227,16 +227,6 @@ describe MergeRequests::RefreshService, services: true do
end end
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 def reload_mrs
@merge_request.reload @merge_request.reload
@fork_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