Skip to content

Commit 3a76127

Browse files
authored
Merge pull request moby#5613 from WnP/git-proxy
fix git http_proxy ignored
2 parents c2c70ac + 4f97acf commit 3a76127

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

util/gitutil/git_cli.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ func (cli *GitCLI) Run(ctx context.Context, args ...string) (_ []byte, err error
134134
if cli.git != "" {
135135
gitBinary = cli.git
136136
}
137+
proxyEnvVars := [...]string{
138+
"HTTP_PROXY", "HTTPS_PROXY", "NO_PROXY", "ALL_PROXY",
139+
"http_proxy", "https_proxy", "no_proxy", "all_proxy",
140+
}
137141

138142
for {
139143
var cmd *exec.Cmd
@@ -190,6 +194,11 @@ func (cli *GitCLI) Run(ctx context.Context, args ...string) (_ []byte, err error
190194
"HOME=/dev/null", // Disable reading from user gitconfig.
191195
"LC_ALL=C", // Ensure consistent output.
192196
}
197+
for _, ev := range proxyEnvVars {
198+
if v, ok := os.LookupEnv(ev); ok {
199+
cmd.Env = append(cmd.Env, ev+"="+v)
200+
}
201+
}
193202
if cli.sshAuthSock != "" {
194203
cmd.Env = append(cmd.Env, "SSH_AUTH_SOCK="+cli.sshAuthSock)
195204
}

0 commit comments

Comments
 (0)