Commit b1a75c7d authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch 'sh-fix-merge-request-stickiness' into 'master'

Clear merge request error on push to source branch

Closes #34186

See merge request gitlab-org/gitlab!32001
parents 58662724 d20a28c4
...@@ -115,6 +115,10 @@ module MergeRequests ...@@ -115,6 +115,10 @@ module MergeRequests
filter_merge_requests(merge_requests).each do |merge_request| filter_merge_requests(merge_requests).each do |merge_request|
if branch_and_project_match?(merge_request) || @push.force_push? if branch_and_project_match?(merge_request) || @push.force_push?
merge_request.reload_diff(current_user) merge_request.reload_diff(current_user)
# Clear existing merge error if the push were directed at the
# source branch. Clearing the error when the target branch
# changes will hide the error from the user.
merge_request.merge_error = nil
elsif merge_request.merge_request_diff.includes_any_commits?(push_commit_ids) elsif merge_request.merge_request_diff.includes_any_commits?(push_commit_ids)
merge_request.reload_diff(current_user) merge_request.reload_diff(current_user)
end end
......
---
title: Clear merge request error on push to source branch
merge_request: 32001
author:
type: fixed
...@@ -94,6 +94,31 @@ describe MergeRequests::RefreshService do ...@@ -94,6 +94,31 @@ describe MergeRequests::RefreshService do
expect(@fork_build_failed_todo).to be_done expect(@fork_build_failed_todo).to be_done
end end
context 'when a merge error exists' do
let(:error_message) { 'This is a merge error' }
before do
@merge_request = create(:merge_request,
source_project: @project,
source_branch: 'feature',
target_branch: 'master',
target_project: @project,
merge_error: error_message)
end
it 'clears merge errors when pushing to the source branch' do
expect { refresh_service.execute(@oldrev, @newrev, 'refs/heads/feature') }
.to change { @merge_request.reload.merge_error }
.from(error_message)
.to(nil)
end
it 'does not clear merge errors when pushing to the target branch' do
expect { refresh_service.execute(@oldrev, @newrev, 'refs/heads/master') }
.not_to change { @merge_request.reload.merge_error }
end
end
it 'reloads source branch MRs memoization' do it 'reloads source branch MRs memoization' do
refresh_service.execute(@oldrev, @newrev, 'refs/heads/master') refresh_service.execute(@oldrev, @newrev, 'refs/heads/master')
......
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