gps: vcs: suppress git password prompts

This commit is contained in:
Jordan Krage 2017-10-08 15:11:00 -05:00
Родитель 4ecb1d1fb9
Коммит 8065bb2db9
2 изменённых файлов: 7 добавлений и 0 удалений

Просмотреть файл

@ -4,6 +4,7 @@ BUG FIXES:
* Releases targeting Windows now have a `.exe` suffix (#1291). * Releases targeting Windows now have a `.exe` suffix (#1291).
* Adaptively recover from dirty and corrupted git repositories in cache (#1279). * Adaptively recover from dirty and corrupted git repositories in cache (#1279).
* Suppress git password prompts in more places (#1357).
IMPROVEMENTS: IMPROVEMENTS:

Просмотреть файл

@ -92,6 +92,8 @@ func (r *gitRepo) get(ctx context.Context) error {
r.Remote(), r.Remote(),
r.LocalPath(), 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 { if out, err := cmd.CombinedOutput(); err != nil {
return newVcsRemoteErrorOr(err, cmd.Args(), string(out), return newVcsRemoteErrorOr(err, cmd.Args(), string(out),
"unable to get repository") "unable to get repository")
@ -110,6 +112,8 @@ func (r *gitRepo) fetch(ctx context.Context) error {
r.RemoteLocation, r.RemoteLocation,
) )
cmd.SetDir(r.LocalPath()) 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 { if out, err := cmd.CombinedOutput(); err != nil {
return newVcsRemoteErrorOr(err, cmd.Args(), string(out), return newVcsRemoteErrorOr(err, cmd.Args(), string(out),
"unable to update repository") "unable to update repository")
@ -142,6 +146,8 @@ func (r *gitRepo) defendAgainstSubmodules(ctx context.Context) error {
"--recursive", "--recursive",
) )
cmd.SetDir(r.LocalPath()) 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 { if out, err := cmd.CombinedOutput(); err != nil {
return newVcsLocalErrorOr(err, cmd.Args(), string(out), return newVcsLocalErrorOr(err, cmd.Args(), string(out),
"unexpected error while defensively updating submodules") "unexpected error while defensively updating submodules")