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>2023-08-30 14:22:45 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2023-08-30 14:38:39 +0300
commit77d5d03d4df12c3dacc0cb5a05a74f9abb1cc6ef (patch)
tree8f78e27909f8b3f4605dd60135be588acd36b578
parent10a46efca33d29ec757c6744b12af54f45461dc1 (diff)
git2go: Move errors used by UserUpdateSubmodule RPC
The "internal/git2go" package still hosts a bunch of errors which are used by the UserUpdateSubmodulie RPC and nothing else. Furthermore, two of the three errors are actually never raised anymore, so there is no point in handling them. Move the single error that is still being used over to where its used.
-rw-r--r--internal/git2go/submodule.go8
-rw-r--r--internal/gitaly/service/operations/submodules.go33
2 files changed, 15 insertions, 26 deletions
diff --git a/internal/git2go/submodule.go b/internal/git2go/submodule.go
deleted file mode 100644
index 757fef6a1..000000000
--- a/internal/git2go/submodule.go
+++ /dev/null
@@ -1,8 +0,0 @@
-package git2go
-
-// Error strings present in the legacy Ruby implementation
-const (
- LegacyErrPrefixInvalidBranch = "Invalid branch"
- LegacyErrPrefixInvalidSubmodulePath = "Invalid submodule path"
- LegacyErrPrefixFailedCommit = "Failed to create commit"
-)
diff --git a/internal/gitaly/service/operations/submodules.go b/internal/gitaly/service/operations/submodules.go
index 1323379be..6ba4911bf 100644
--- a/internal/gitaly/service/operations/submodules.go
+++ b/internal/gitaly/service/operations/submodules.go
@@ -9,13 +9,17 @@ import (
"github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
"gitlab.com/gitlab-org/gitaly/v16/internal/git"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/localrepo"
- "gitlab.com/gitlab-org/gitaly/v16/internal/git2go"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/hook/updateref"
"gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage"
"gitlab.com/gitlab-org/gitaly/v16/internal/structerr"
"gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb"
)
+// Error strings present in the legacy Ruby implementation.
+const (
+ legacyErrPrefixInvalidSubmodulePath = "Invalid submodule path"
+)
+
//nolint:revive // This is unintentionally missing documentation.
func (s *Server) UserUpdateSubmodule(ctx context.Context, req *gitalypb.UserUpdateSubmoduleRequest) (*gitalypb.UserUpdateSubmoduleResponse, error) {
if err := s.locator.ValidateRepository(req.GetRepository()); err != nil {
@@ -80,21 +84,14 @@ func (s *Server) UserUpdateSubmodule(ctx context.Context, req *gitalypb.UserUpda
errStr := strings.TrimSpace(err.Error())
var resp *gitalypb.UserUpdateSubmoduleResponse
- for _, legacyErr := range []string{
- git2go.LegacyErrPrefixInvalidBranch,
- git2go.LegacyErrPrefixInvalidSubmodulePath,
- git2go.LegacyErrPrefixFailedCommit,
- } {
- if strings.Contains(errStr, legacyErr) {
- resp = &gitalypb.UserUpdateSubmoduleResponse{
- CommitError: legacyErr,
- }
- ctxlogrus.
- Extract(ctx).
- WithError(err).
- Error("UserUpdateSubmodule: git2go subcommand failure")
- break
+ if strings.Contains(errStr, legacyErrPrefixInvalidSubmodulePath) {
+ resp = &gitalypb.UserUpdateSubmoduleResponse{
+ CommitError: legacyErrPrefixInvalidSubmodulePath,
}
+ ctxlogrus.
+ Extract(ctx).
+ WithError(err).
+ Error("UserUpdateSubmodule: git2go subcommand failure")
}
if strings.Contains(errStr, "is already at") {
resp = &gitalypb.UserUpdateSubmoduleResponse{
@@ -200,7 +197,7 @@ func (s *Server) updateSubmodule(ctx context.Context, quarantineRepo *localrepo.
)
if err != nil {
if errors.Is(err, git.ErrReferenceNotFound) {
- return "", fmt.Errorf("submodule: %s", git2go.LegacyErrPrefixInvalidSubmodulePath)
+ return "", fmt.Errorf("submodule: %s", legacyErrPrefixInvalidSubmodulePath)
}
return "", fmt.Errorf("error reading tree: %w", err)
@@ -212,7 +209,7 @@ func (s *Server) updateSubmodule(ctx context.Context, quarantineRepo *localrepo.
replaceWith := git.ObjectID(req.GetCommitSha())
if t.Type != localrepo.Submodule {
- return fmt.Errorf("submodule: %s", git2go.LegacyErrPrefixInvalidSubmodulePath)
+ return fmt.Errorf("submodule: %s", legacyErrPrefixInvalidSubmodulePath)
}
if replaceWith == t.OID {
@@ -228,7 +225,7 @@ func (s *Server) updateSubmodule(ctx context.Context, quarantineRepo *localrepo.
},
); err != nil {
if err == localrepo.ErrEntryNotFound {
- return "", fmt.Errorf("submodule: %s", git2go.LegacyErrPrefixInvalidSubmodulePath)
+ return "", fmt.Errorf("submodule: %s", legacyErrPrefixInvalidSubmodulePath)
}
var git2GoErr *legacyGit2GoSubmoduleAlreadyAtShaError