Skip to content
Snippets Groups Projects
Commit 8cf0ea44 authored by Jacob Vosmaer (GitLab)'s avatar Jacob Vosmaer (GitLab)
Browse files

Handle Gitaly aborted merge due to branch update

parent 48dacd5e
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -101,6 +101,7 @@ module Gitlab
request_enum.push(Gitaly::UserMergeBranchRequest.new(apply: true))
 
branch_update = response_enum.next.branch_update
return if branch_update.nil?
raise Gitlab::Git::CommitError.new('failed to apply merge to branch') unless branch_update.commit_id.present?
 
Gitlab::Git::OperationService::BranchUpdate.from_gitaly(branch_update)
Loading
Loading
Loading
Loading
@@ -1719,6 +1719,20 @@ describe Gitlab::Git::Repository, seed_helper: true do
expect(result.repo_created).to eq(false)
expect(result.branch_created).to eq(false)
end
it 'returns nil if there was a concurrent branch update' do
concurrent_update_id = '33f3729a45c02fc67d00adb1b8bca394b0e761d9'
result = repository.merge(user, source_sha, target_branch, 'Test merge') do
# This ref update should make the merge fail
repository.write_ref(Gitlab::Git::BRANCH_REF_PREFIX + target_branch, concurrent_update_id)
end
# This 'nil' signals that the merge was not applied
expect(result).to be_nil
# Our concurrent ref update should not have been reversed
expect(repository.find_branch(target_branch).target).to eq(concurrent_update_id)
end
end
 
context 'with gitaly' do
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment