Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2020-10-22 16:24:20 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2020-10-22 16:33:08 +0300
commit9d1e847ab180e1c31ded0aeff34d14bea50c52af (patch)
tree3001b4e3610bbda00bc118c4f6479b7f6a0fcaf8 /internal
parent0ebfb705b79a8baecc1db46f31761f83f4e471f9 (diff)
operations: Return correct error code when merge fails
When the UserMergeToRef fails because of a conflict, then it's currently not using any gRPC error code but instead directly returns an internal error, where the Ruby implementation returned a PreconditionFailed error instead. Fix this discrepancy by also returning a FailedPrecondition error. Adjust a test to pin down this error case.
Diffstat (limited to 'internal')
-rw-r--r--internal/gitaly/service/operations/merge.go2
-rw-r--r--internal/gitaly/service/operations/merge_test.go1
2 files changed, 2 insertions, 1 deletions
diff --git a/internal/gitaly/service/operations/merge.go b/internal/gitaly/service/operations/merge.go
index 194d48786..cd8163d35 100644
--- a/internal/gitaly/service/operations/merge.go
+++ b/internal/gitaly/service/operations/merge.go
@@ -460,7 +460,7 @@ func (s *server) userMergeToRef(ctx context.Context, request *gitalypb.UserMerge
return nil, helper.ErrInvalidArgument(err)
}
//nolint:stylecheck
- return nil, fmt.Errorf("Failed to create merge commit for source_sha %s and target_sha %s at %s", sourceRef, string(request.TargetRef), refName)
+ return nil, helper.ErrPreconditionFailed(fmt.Errorf("Failed to create merge commit for source_sha %s and target_sha %s at %s", sourceRef, string(request.TargetRef), refName))
}
// ... and move branch from target ref to the merge commit. The Ruby
diff --git a/internal/gitaly/service/operations/merge_test.go b/internal/gitaly/service/operations/merge_test.go
index d165c6f27..19d9b6c04 100644
--- a/internal/gitaly/service/operations/merge_test.go
+++ b/internal/gitaly/service/operations/merge_test.go
@@ -681,6 +681,7 @@ func testConflictsOnUserMergeToRefRequest(t *testing.T, ctx context.Context) {
_, err := client.UserMergeToRef(ctx, request)
require.Error(t, err)
+ testhelper.RequireGrpcError(t, err, codes.FailedPrecondition)
})
}