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

Commit

Permalink
Include proxy env variables in git operations if set
Browse files Browse the repository at this point in the history
Signed-off-by: Hidde Beydals <hello@hidde.co>
  • Loading branch information
hiddeco committed Nov 25, 2018
1 parent bca4041 commit b9f2e5b
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 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 Down Expand Up @@ -289,7 +290,18 @@ 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 proxy environment variables if set
for _, e := range os.Environ() {
pair := strings.SplitN(e, "=", 2)
if pair[0] != "HTTP_PROXY" && pair[0] != "HTTPS_PROXY" && pair[0] != "NO_PROXY" {
continue
}
env = append(env, e)
}

return env
}

// check returns true if there are changes locally.
Expand Down

0 comments on commit b9f2e5b

Please sign in to comment.