diff options
author | James Fargher <jfargher@gitlab.com> | 2022-08-04 18:00:45 +0300 |
---|---|---|
committer | James Fargher <jfargher@gitlab.com> | 2022-08-04 18:00:45 +0300 |
commit | 782d0a2ff7fb1e65759398a32470da13f8411528 (patch) | |
tree | a55a741abe9507aa18b4c9b77651739451310075 | |
parent | 993d944ebeea3e0ec8157481f125f9c70161ae4a (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.go | 45 |
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 { |