gitserver: Remove runWithRemoteOpts (#39150)

It was just a thin wrapper around runWith and made it harder to know
what as being passed to runWith from the call site.
This commit is contained in:
Ryan Slade 2022-07-20 17:33:19 +02:00 committed by GitHub
parent 0af57f0d19
commit e5c9d4f739
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 10 deletions

View File

@ -2079,7 +2079,7 @@ func (s *Server) doClone(ctx context.Context, repo api.RepoName, dir GitDir, syn
go readCloneProgress(newURLRedactor(remoteURL), lock, pr, repo)
if output, err := runWithRemoteOpts(ctx, cmd, pw); err != nil {
if output, err := runWith(ctx, cmd, true, pw); err != nil {
return errors.Wrapf(err, "clone failed. Output: %s", string(output))
}
@ -2542,7 +2542,7 @@ func setHEAD(ctx context.Context, dir GitDir, syncer VCSSyncer, repo api.RepoNam
return errors.Wrap(err, "get remote show command")
}
dir.Set(cmd)
output, err := runWithRemoteOpts(ctx, cmd, nil)
output, err := runWith(ctx, cmd, true, nil)
if err != nil {
logger.Error("Failed to fetch remote info", log.String("repo", string(repo)), log.Error(err), log.String("output", string(output)))
return errors.Wrap(err, "failed to fetch remote info")

View File

@ -134,12 +134,8 @@ var tlsExternal = conf.Cached(func() any {
}
})
func runWithRemoteOpts(ctx context.Context, cmd *exec.Cmd, progress io.Writer) ([]byte, error) {
return runWith(ctx, cmd, true, progress)
}
// runWithRemoteOpts runs the command after applying the remote options.
// If progress is not nil, all output is written to it in a separate goroutine.
// runWith runs the command after applying the remote options. If progress is not
// nil, all output is written to it in a separate goroutine.
func runWith(ctx context.Context, cmd *exec.Cmd, configRemoteOpts bool, progress io.Writer) ([]byte, error) {
if configRemoteOpts {
// Inherit process environment. This allows admins to configure
@ -154,7 +150,7 @@ func runWith(ctx context.Context, cmd *exec.Cmd, configRemoteOpts bool, progress
Bytes() []byte
}
logger := log.Scoped("runWith", "runWithRemoteOpts runs the command after applying the remote options")
logger := log.Scoped("runWith", "runWith runs the command after applying the remote options")
if progress != nil {
var pw progressWriter

View File

@ -31,7 +31,7 @@ func (s *GitRepoSyncer) IsCloneable(ctx context.Context, remoteURL *vcs.URL) err
defer cancel()
cmd := exec.CommandContext(ctx, "git", args...)
out, err := runWithRemoteOpts(ctx, cmd, nil)
out, err := runWith(ctx, cmd, true, nil)
if err != nil {
if ctxerr := ctx.Err(); ctxerr != nil {
err = ctxerr