From 2d7da573dad8b0901663ae66c162dbddb9ba6370 Mon Sep 17 00:00:00 2001 From: Norwin Roosen Date: Sun, 16 May 2021 18:42:30 +0200 Subject: [PATCH 1/2] don't prompt interactively for clone credentials --- modules/git/repo.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/git/repo.go b/modules/git/repo.go index 515899ab04984..a4d78a3c21702 100644 --- a/modules/git/repo.go +++ b/modules/git/repo.go @@ -147,7 +147,11 @@ func CloneWithArgs(ctx context.Context, from, to string, args []string, opts Clo opts.Timeout = -1 } - _, err = cmd.RunTimeout(opts.Timeout) + env := []string{ + "GIT_TERMINAL_PROMPT=0", // avoid prompting for credentials interactively, supported since git v2.3 + } + + _, err = cmd.RunInDirTimeoutEnv(env, opts.Timeout, "") return err } From 9269dee9747c3298eda0773e77595ff6dbceb5b9 Mon Sep 17 00:00:00 2001 From: Norwin Roosen Date: Mon, 17 May 2021 02:26:03 +0200 Subject: [PATCH 2/2] apply GIT_TERMINAL_PROMPT=0 to all git cmds --- modules/git/command.go | 10 ++++++++-- modules/git/repo.go | 6 +----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/modules/git/command.go b/modules/git/command.go index fe258954628e0..ef78464d5f1c0 100644 --- a/modules/git/command.go +++ b/modules/git/command.go @@ -124,12 +124,18 @@ func (c *Command) RunInDirTimeoutEnvFullPipelineFunc(env []string, timeout time. cmd := exec.CommandContext(ctx, c.name, c.args...) if env == nil { - cmd.Env = append(os.Environ(), fmt.Sprintf("LC_ALL=%s", DefaultLocale)) + cmd.Env = os.Environ() } else { cmd.Env = env - cmd.Env = append(cmd.Env, fmt.Sprintf("LC_ALL=%s", DefaultLocale)) } + cmd.Env = append( + cmd.Env, + fmt.Sprintf("LC_ALL=%s", DefaultLocale), + // avoid prompting for credentials interactively, supported since git v2.3 + "GIT_TERMINAL_PROMPT=0", + ) + // TODO: verify if this is still needed in golang 1.15 if goVersionLessThan115 { cmd.Env = append(cmd.Env, "GODEBUG=asyncpreemptoff=1") diff --git a/modules/git/repo.go b/modules/git/repo.go index a4d78a3c21702..515899ab04984 100644 --- a/modules/git/repo.go +++ b/modules/git/repo.go @@ -147,11 +147,7 @@ func CloneWithArgs(ctx context.Context, from, to string, args []string, opts Clo opts.Timeout = -1 } - env := []string{ - "GIT_TERMINAL_PROMPT=0", // avoid prompting for credentials interactively, supported since git v2.3 - } - - _, err = cmd.RunInDirTimeoutEnv(env, opts.Timeout, "") + _, err = cmd.RunTimeout(opts.Timeout) return err }