Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
Merge pull request #1556 from weaveworks/1535-http-proxy
Browse files Browse the repository at this point in the history
Include proxy env variables in git operations if set
  • Loading branch information
hiddeco committed Dec 3, 2018
2 parents 8f30cc0 + 0cd25ea commit 5cdd314
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion git/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"io"
"io/ioutil"
"os"
"os/exec"
"strings"

Expand All @@ -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,
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 5cdd314

Please sign in to comment.