Skip to content

Commit 3ff2ae1

Browse files
authored
fix: output askpass to stderr (#7034)
This fixes askpass not outputting a prompt.
1 parent 5bd0291 commit 3ff2ae1

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

cli/gitaskpass.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,17 @@ func (r *RootCmd) gitAskpass() *clibase.Cmd {
5151
}
5252
if token.URL != "" {
5353
if err := openURL(inv, token.URL); err == nil {
54-
cliui.Infof(inv.Stdout, "Your browser has been opened to authenticate with Git:\n\n\t%s\n\n", token.URL)
54+
cliui.Infof(inv.Stderr, "Your browser has been opened to authenticate with Git:\n\n\t%s\n\n", token.URL)
5555
} else {
56-
cliui.Infof(inv.Stdout, "Open the following URL to authenticate with Git:\n\n\t%s\n\n", token.URL)
56+
cliui.Infof(inv.Stderr, "Open the following URL to authenticate with Git:\n\n\t%s\n\n", token.URL)
5757
}
5858

5959
for r := retry.New(250*time.Millisecond, 10*time.Second); r.Wait(ctx); {
6060
token, err = client.GitAuth(ctx, host, true)
6161
if err != nil {
6262
continue
6363
}
64-
cliui.Infof(inv.Stdout, "You've been authenticated with Git!\n")
64+
cliui.Infof(inv.Stderr, "You've been authenticated with Git!\n")
6565
break
6666
}
6767
}

cli/gitaskpass_test.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -86,17 +86,20 @@ func TestGitAskpass(t *testing.T) {
8686

8787
inv, _ := clitest.New(t, "--agent-url", url, "--no-open", "Username for 'https://github.com':")
8888
inv.Environ.Set("GIT_PREFIX", "/")
89-
pty := ptytest.New(t)
90-
inv.Stdout = pty.Output()
89+
stdout := ptytest.New(t)
90+
inv.Stdout = stdout.Output()
91+
stderr := ptytest.New(t)
92+
inv.Stderr = stderr.Output()
9193
go func() {
9294
err := inv.Run()
9395
assert.NoError(t, err)
9496
}()
9597
<-poll
98+
stderr.ExpectMatch("Open the following URL to authenticate")
9699
resp.Store(&agentsdk.GitAuthResponse{
97100
Username: "username",
98101
Password: "password",
99102
})
100-
pty.ExpectMatch("username")
103+
stdout.ExpectMatch("username")
101104
})
102105
}

0 commit comments

Comments
 (0)