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

Commit 832c144

Browse files
authored
Merge pull request #1357 from jmank88/git-prompt
gps: vcs: suppress git password prompts
2 parents 4ecb1d1 + 913f48c commit 832c144

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ BUG FIXES:
44

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

89
IMPROVEMENTS:
910

gps/vcs_repo.go

+6
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ func (r *gitRepo) get(ctx context.Context) error {
9292
r.Remote(),
9393
r.LocalPath(),
9494
)
95+
// Ensure no prompting for PWs
96+
cmd.SetEnv(append([]string{"GIT_ASKPASS=", "GIT_TERMINAL_PROMPT=0"}, os.Environ()...))
9597
if out, err := cmd.CombinedOutput(); err != nil {
9698
return newVcsRemoteErrorOr(err, cmd.Args(), string(out),
9799
"unable to get repository")
@@ -110,6 +112,8 @@ func (r *gitRepo) fetch(ctx context.Context) error {
110112
r.RemoteLocation,
111113
)
112114
cmd.SetDir(r.LocalPath())
115+
// Ensure no prompting for PWs
116+
cmd.SetEnv(append([]string{"GIT_ASKPASS=", "GIT_TERMINAL_PROMPT=0"}, os.Environ()...))
113117
if out, err := cmd.CombinedOutput(); err != nil {
114118
return newVcsRemoteErrorOr(err, cmd.Args(), string(out),
115119
"unable to update repository")
@@ -142,6 +146,8 @@ func (r *gitRepo) defendAgainstSubmodules(ctx context.Context) error {
142146
"--recursive",
143147
)
144148
cmd.SetDir(r.LocalPath())
149+
// Ensure no prompting for PWs
150+
cmd.SetEnv(append([]string{"GIT_ASKPASS=", "GIT_TERMINAL_PROMPT=0"}, os.Environ()...))
145151
if out, err := cmd.CombinedOutput(); err != nil {
146152
return newVcsLocalErrorOr(err, cmd.Args(), string(out),
147153
"unexpected error while defensively updating submodules")

gps/vcs_source_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ func testHgSourceInteractions(t *testing.T) {
525525
}
526526

527527
func TestGitSourceListVersionsNoHEAD(t *testing.T) {
528-
t.Parallel()
528+
// t.Parallel()
529529

530530
requiresBins(t, "git")
531531

@@ -582,7 +582,7 @@ func TestGitSourceListVersionsNoHEAD(t *testing.T) {
582582
}
583583

584584
func TestGitSourceListVersionsNoDupes(t *testing.T) {
585-
t.Parallel()
585+
// t.Parallel()
586586

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

651651
func TestGitSourceAdaptiveCleanup(t *testing.T) {
652-
t.Parallel()
652+
// t.Parallel()
653653

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

0 commit comments

Comments
 (0)