aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNorwin <noerw@users.noreply.github.com>2021-05-17 10:59:31 +0000
committerGitHub <noreply@github.com>2021-05-17 18:59:31 +0800
commita137ee7a68b2246507b8def2de67a4553661a28f (patch)
tree8f09a1f6c4704634e4bda162ef477eb62311b548
parent131b59ef8907a30506351b709b50a34def1ff11e (diff)
downloadgitea-a137ee7a68b2246507b8def2de67a4553661a28f.tar.gz
gitea-a137ee7a68b2246507b8def2de67a4553661a28f.zip
git migration: don't prompt interactively for clone credentials (#15902)
* don't prompt interactively for clone credentials * apply GIT_TERMINAL_PROMPT=0 to all git cmds Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
-rw-r--r--modules/git/command.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/modules/git/command.go b/modules/git/command.go
index fe25895462..ef78464d5f 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")