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:
authorJames Fargher <jfargher@gitlab.com>2022-08-04 18:00:45 +0300
committerJames Fargher <jfargher@gitlab.com>2022-08-04 18:00:45 +0300
commit782d0a2ff7fb1e65759398a32470da13f8411528 (patch)
treea55a741abe9507aa18b4c9b77651739451310075
parent993d944ebeea3e0ec8157481f125f9c70161ae4a (diff)
repository: Capture stderr on CreateForkcreate_fork_errors
CreateFork had been returning unhelpful exit status errors that are too ambiguous to allow for debugging.
-rw-r--r--internal/gitaly/service/repository/create_fork.go45
1 files changed, 27 insertions, 18 deletions
diff --git a/internal/gitaly/service/repository/create_fork.go b/internal/gitaly/service/repository/create_fork.go
index ea9fd3949..7566a9344 100644
--- a/internal/gitaly/service/repository/create_fork.go
+++ b/internal/gitaly/service/repository/create_fork.go
@@ -4,6 +4,7 @@ import (
"context"
"fmt"
"os"
+ "strings"
"gitlab.com/gitlab-org/gitaly/v15/internal/git"
"gitlab.com/gitlab-org/gitaly/v15/internal/helper"
@@ -38,30 +39,38 @@ func (s *server) CreateFork(ctx context.Context, req *gitalypb.CreateForkRequest
// Ideally we'd just fetch into the already-created repo, but that wouldn't
// allow us to easily set up HEAD to point to the correct ref. We thus have
// no easy choice but to use git-clone(1).
- cmd, err := s.gitCmdFactory.NewWithoutRepo(ctx, git.SubCmd{
- Name: "clone",
- Flags: []git.Option{
- git.Flag{Name: "--bare"},
+ var stderr strings.Builder
+ cmd, err := s.gitCmdFactory.NewWithoutRepo(ctx,
+ git.SubCmd{
+ Name: "clone",
+ Flags: []git.Option{
+ git.Flag{Name: "--bare"},
+ git.Flag{Name: "--quiet"},
+ },
+ Args: []string{
+ git.InternalGitalyURL,
+ targetPath,
+ },
},
- Args: []string{
- git.InternalGitalyURL,
- targetPath,
- },
- }, git.WithInternalFetch(&gitalypb.SSHUploadPackRequest{
- Repository: sourceRepository,
- }), git.WithConfig(git.ConfigPair{
- // Disable consistency checks for fetched objects when creating a
- // fork. We don't want to end up in a situation where it's
- // impossible to create forks we already have anyway because we have
- // e.g. retroactively tightened the consistency checks.
- Key: "fetch.fsckObjects", Value: "false",
- }), git.WithDisabledHooks())
+ git.WithInternalFetch(&gitalypb.SSHUploadPackRequest{
+ Repository: sourceRepository,
+ }),
+ git.WithConfig(git.ConfigPair{
+ // Disable consistency checks for fetched objects when creating a
+ // fork. We don't want to end up in a situation where it's
+ // impossible to create forks we already have anyway because we have
+ // e.g. retroactively tightened the consistency checks.
+ Key: "fetch.fsckObjects", Value: "false",
+ }),
+ git.WithDisabledHooks(),
+ git.WithStderr(&stderr),
+ )
if err != nil {
return fmt.Errorf("spawning fetch: %w", err)
}
if err := cmd.Wait(); err != nil {
- return fmt.Errorf("fetching source repo: %w", err)
+ return fmt.Errorf("fetching source repo: %w, stderr: %q", err, stderr.String())
}
if err := s.removeOriginInRepo(ctx, repo); err != nil {