diff --git a/git/operations.go b/git/operations.go index 732e306df..0f175c1e3 100644 --- a/git/operations.go +++ b/git/operations.go @@ -7,6 +7,7 @@ import ( "fmt" "io" "io/ioutil" + "os" "os/exec" "strings" @@ -18,6 +19,9 @@ import ( // If true, every git invocation will be echoed to stdout const trace = false +// Env vars that are allowed to be inherited from the os +var allowedEnvVars = []string{"http_proxy", "https_proxy", "no_proxy"} + func config(ctx context.Context, workingDir, user, email string) error { for k, v := range map[string]string{ "user.name": user, @@ -289,7 +293,16 @@ func execGitCmd(ctx context.Context, dir string, out io.Writer, args ...string) } func env() []string { - return []string{"GIT_TERMINAL_PROMPT=0"} + env := []string{"GIT_TERMINAL_PROMPT=0"} + + // include allowed env vars from os + for _, k := range allowedEnvVars { + if v, ok := os.LookupEnv(k); ok { + env = append(env, k+"="+v) + } + } + + return env } // check returns true if there are changes locally.