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-11-09 12:59:50 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2020-11-09 15:51:52 +0300
commit9b072111c8de7807b69f04a5d98df4b61824fc2e (patch)
tree7e6e2d71be2ee283897559068eba37f3a379d88c
parent3607cfccb573b16a63714539a982dbacc5179af7 (diff)
operations: Fix error message when UserMergeToRef conflicts
When creating the merge commit in UserMergeToRef fails with a conflicf, then we create an error messages "Failed to create merge commit" with some details filled in. The error message currently confuses the target SHA and target reference though. Fix the error message and add a test to verify we got it correct.
-rw-r--r--changelogs/unreleased/pks-operations-user-merge-to-ref-errmsg.yml5
-rw-r--r--internal/gitaly/service/operations/merge.go2
-rw-r--r--internal/gitaly/service/operations/merge_test.go4
3 files changed, 8 insertions, 3 deletions
diff --git a/changelogs/unreleased/pks-operations-user-merge-to-ref-errmsg.yml b/changelogs/unreleased/pks-operations-user-merge-to-ref-errmsg.yml
new file mode 100644
index 000000000..c6736d659
--- /dev/null
+++ b/changelogs/unreleased/pks-operations-user-merge-to-ref-errmsg.yml
@@ -0,0 +1,5 @@
+---
+title: 'operations: Fix error message when UserMergeToRef conflicts'
+merge_request: 2756
+author:
+type: fixed
diff --git a/internal/gitaly/service/operations/merge.go b/internal/gitaly/service/operations/merge.go
index 31a0ed521..e953dd95b 100644
--- a/internal/gitaly/service/operations/merge.go
+++ b/internal/gitaly/service/operations/merge.go
@@ -438,7 +438,7 @@ func (s *server) userMergeToRef(ctx context.Context, request *gitalypb.UserMerge
return nil, helper.ErrInvalidArgument(err)
}
//nolint:stylecheck
- 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))
+ return nil, helper.ErrPreconditionFailedf("Failed to create merge commit for source_sha %s and target_sha %s at %s", sourceRef, ref, string(request.TargetRef))
}
// ... 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 3ae4da5cf..42df4b6de 100644
--- a/internal/gitaly/service/operations/merge_test.go
+++ b/internal/gitaly/service/operations/merge_test.go
@@ -19,6 +19,7 @@ import (
"gitlab.com/gitlab-org/gitaly/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
"google.golang.org/grpc/codes"
+ "google.golang.org/grpc/status"
)
var (
@@ -650,8 +651,7 @@ func testConflictsOnUserMergeToRefRequest(t *testing.T, ctx context.Context) {
request.AllowConflicts = false
_, err := client.UserMergeToRef(ctx, request)
- require.Error(t, err)
- testhelper.RequireGrpcError(t, err, codes.FailedPrecondition)
+ require.Equal(t, status.Error(codes.FailedPrecondition, "Failed to create merge commit for source_sha 1450cd639e0bc6721eb02800169e464f212cde06 and target_sha 824be604a34828eb682305f0d963056cfac87b2d at refs/merge-requests/x/written"), err)
})
}