diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2018-01-04 11:01:02 +0000 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2018-01-04 11:01:02 +0000 |
commit | a0ae88613598a2b0fddad4e7a6f779827257f103 (patch) | |
tree | 86ed37a33076be780cc75f8c1d6806a4bbe57f22 | |
parent | 0eaa3c552e66a3153dd04b4b6422ff87d08fcd24 (diff) | |
parent | 449b59ec69f7da2be9e75fdaf282592f048b9853 (diff) | |
download | gitlab-ce-a0ae88613598a2b0fddad4e7a6f779827257f103.tar.gz |
Merge branch 'gitaly-merge-nil' into 'master'
Handle Gitaly aborted merge due to branch update
Closes gitaly#854
See merge request gitlab-org/gitlab-ce!16116
-rw-r--r-- | lib/gitlab/gitaly_client/operation_service.rb | 1 | ||||
-rw-r--r-- | spec/lib/gitlab/git/repository_spec.rb | 14 |
2 files changed, 15 insertions, 0 deletions
diff --git a/lib/gitlab/gitaly_client/operation_service.rb b/lib/gitlab/gitaly_client/operation_service.rb index c7732764880..ae1753ff0ae 100644 --- a/lib/gitlab/gitaly_client/operation_service.rb +++ b/lib/gitlab/gitaly_client/operation_service.rb @@ -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) diff --git a/spec/lib/gitlab/git/repository_spec.rb b/spec/lib/gitlab/git/repository_spec.rb index 477bf0b8d68..2531e1e7507 100644 --- a/spec/lib/gitlab/git/repository_spec.rb +++ b/spec/lib/gitlab/git/repository_spec.rb @@ -1727,6 +1727,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 undone + expect(repository.find_branch(target_branch).target).to eq(concurrent_update_id) + end end context 'with gitaly' do |