diff options
author | Adam Niedzielski <adamsunday@gmail.com> | 2016-11-18 13:14:44 +0300 |
---|---|---|
committer | Adam Niedzielski <adamsunday@gmail.com> | 2016-11-21 15:26:26 +0300 |
commit | 9e9965ba5ce5a2acca97325412c63eed398ef80b (patch) | |
tree | 365949ae69b51937ba3b6c06fb3fecfcaeb3923a | |
parent | 5018bdcd0ab45df924956125f9d11f66847f8164 (diff) |
Revert "Do not create a MergeRequestDiff record when source branch is deleted"
This reverts commit f913170e2f76ef44800f0272cb7fb40b9d6709ee.
3 files changed, 9 insertions, 26 deletions
diff --git a/app/services/merge_requests/refresh_service.rb b/app/services/merge_requests/refresh_service.rb index 4a7e6930842..22596b4014a 100644 --- a/app/services/merge_requests/refresh_service.rb +++ b/app/services/merge_requests/refresh_service.rb @@ -60,7 +60,15 @@ module MergeRequests merge_requests = filter_merge_requests(merge_requests) 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 end end @@ -165,16 +173,5 @@ module MergeRequests 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 diff --git a/changelogs/unreleased/fix-merge-request-screen-deleted-source-branch.yml b/changelogs/unreleased/fix-merge-request-screen-deleted-source-branch.yml deleted file mode 100644 index a6bee989f6d..00000000000 --- a/changelogs/unreleased/fix-merge-request-screen-deleted-source-branch.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Do not create a MergeRequestDiff record when source branch is deleted -merge_request: 7481 -author: diff --git a/spec/services/merge_requests/refresh_service_spec.rb b/spec/services/merge_requests/refresh_service_spec.rb index 0220f7e1db2..e515bc9f89c 100644 --- a/spec/services/merge_requests/refresh_service_spec.rb +++ b/spec/services/merge_requests/refresh_service_spec.rb @@ -227,16 +227,6 @@ describe MergeRequests::RefreshService, services: true do 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 |