Skip to content
This repository has been archived by the owner on Sep 9, 2020. It is now read-only.

gps: vcs: suppress git password prompts #1357

Merged
merged 2 commits into from
Nov 14, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ BUG FIXES:

* Releases targeting Windows now have a `.exe` suffix (#1291).
* Adaptively recover from dirty and corrupted git repositories in cache (#1279).
* Suppress git password prompts in more places (#1357).

IMPROVEMENTS:

Expand Down
6 changes: 6 additions & 0 deletions gps/vcs_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ func (r *gitRepo) get(ctx context.Context) error {
r.Remote(),
r.LocalPath(),
)
// Ensure no prompting for PWs
cmd.SetEnv(append([]string{"GIT_ASKPASS=", "GIT_TERMINAL_PROMPT=0"}, os.Environ()...))
if out, err := cmd.CombinedOutput(); err != nil {
return newVcsRemoteErrorOr(err, cmd.Args(), string(out),
"unable to get repository")
Expand All @@ -110,6 +112,8 @@ func (r *gitRepo) fetch(ctx context.Context) error {
r.RemoteLocation,
)
cmd.SetDir(r.LocalPath())
// Ensure no prompting for PWs
cmd.SetEnv(append([]string{"GIT_ASKPASS=", "GIT_TERMINAL_PROMPT=0"}, os.Environ()...))
if out, err := cmd.CombinedOutput(); err != nil {
return newVcsRemoteErrorOr(err, cmd.Args(), string(out),
"unable to update repository")
Expand Down Expand Up @@ -142,6 +146,8 @@ func (r *gitRepo) defendAgainstSubmodules(ctx context.Context) error {
"--recursive",
)
cmd.SetDir(r.LocalPath())
// Ensure no prompting for PWs
cmd.SetEnv(append([]string{"GIT_ASKPASS=", "GIT_TERMINAL_PROMPT=0"}, os.Environ()...))
if out, err := cmd.CombinedOutput(); err != nil {
return newVcsLocalErrorOr(err, cmd.Args(), string(out),
"unexpected error while defensively updating submodules")
Expand Down