diff --git a/cli/gitaskpass.go b/cli/gitaskpass.go index cbf5bd3315ad2..14822b9616293 100644 --- a/cli/gitaskpass.go +++ b/cli/gitaskpass.go @@ -51,9 +51,9 @@ func (r *RootCmd) gitAskpass() *clibase.Cmd { } if token.URL != "" { if err := openURL(inv, token.URL); err == nil { - cliui.Infof(inv.Stdout, "Your browser has been opened to authenticate with Git:\n\n\t%s\n\n", token.URL) + cliui.Infof(inv.Stderr, "Your browser has been opened to authenticate with Git:\n\n\t%s\n\n", token.URL) } else { - cliui.Infof(inv.Stdout, "Open the following URL to authenticate with Git:\n\n\t%s\n\n", token.URL) + cliui.Infof(inv.Stderr, "Open the following URL to authenticate with Git:\n\n\t%s\n\n", token.URL) } for r := retry.New(250*time.Millisecond, 10*time.Second); r.Wait(ctx); { @@ -61,7 +61,7 @@ func (r *RootCmd) gitAskpass() *clibase.Cmd { if err != nil { continue } - cliui.Infof(inv.Stdout, "You've been authenticated with Git!\n") + cliui.Infof(inv.Stderr, "You've been authenticated with Git!\n") break } } diff --git a/cli/gitaskpass_test.go b/cli/gitaskpass_test.go index db64a522aeb57..809bc1035005f 100644 --- a/cli/gitaskpass_test.go +++ b/cli/gitaskpass_test.go @@ -86,17 +86,20 @@ func TestGitAskpass(t *testing.T) { inv, _ := clitest.New(t, "--agent-url", url, "--no-open", "Username for 'https://github.com':") inv.Environ.Set("GIT_PREFIX", "/") - pty := ptytest.New(t) - inv.Stdout = pty.Output() + stdout := ptytest.New(t) + inv.Stdout = stdout.Output() + stderr := ptytest.New(t) + inv.Stderr = stderr.Output() go func() { err := inv.Run() assert.NoError(t, err) }() <-poll + stderr.ExpectMatch("Open the following URL to authenticate") resp.Store(&agentsdk.GitAuthResponse{ Username: "username", Password: "password", }) - pty.ExpectMatch("username") + stdout.ExpectMatch("username") }) }