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

Commit

Permalink
Merge pull request #1357 from jmank88/git-prompt
Browse files Browse the repository at this point in the history
gps: vcs: suppress git password prompts
  • Loading branch information
sdboyer authored Nov 14, 2017
2 parents 4ecb1d1 + 913f48c commit 832c144
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
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
6 changes: 3 additions & 3 deletions gps/vcs_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ func testHgSourceInteractions(t *testing.T) {
}

func TestGitSourceListVersionsNoHEAD(t *testing.T) {
t.Parallel()
// t.Parallel()

requiresBins(t, "git")

Expand Down Expand Up @@ -582,7 +582,7 @@ func TestGitSourceListVersionsNoHEAD(t *testing.T) {
}

func TestGitSourceListVersionsNoDupes(t *testing.T) {
t.Parallel()
// t.Parallel()

// This test is slowish, skip it on -short
if testing.Short() {
Expand Down Expand Up @@ -649,7 +649,7 @@ func TestGitSourceListVersionsNoDupes(t *testing.T) {
}

func TestGitSourceAdaptiveCleanup(t *testing.T) {
t.Parallel()
// t.Parallel()

// This test is slowish, skip it on -short
if testing.Short() {
Expand Down

0 comments on commit 832c144

Please sign in to comment.