]> Cypherpunks repositories - gostls13.git/commitdiff
[release-branch.go1.24] cmd/go: initialize req.Header when loading git credential
authorQuan Tong <quantonganh@gmail.com>
Fri, 7 Feb 2025 11:42:26 +0000 (18:42 +0700)
committerGopher Robot <gobot@golang.org>
Wed, 12 Feb 2025 19:16:33 +0000 (11:16 -0800)
Fixes #71687

Change-Id: I3d733a50b4451dfb571aba91a28387ba9e0614dc
Reviewed-on: https://go-review.googlesource.com/c/go/+/647615
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
(cherry picked from commit 58834c3ee08ea85b764c7cc3318ce7a68ea92cbd)
Reviewed-on: https://go-review.googlesource.com/c/go/+/648936
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Bypass: Dmitri Shuralyov <dmitshur@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>

src/cmd/go/internal/auth/auth.go
src/cmd/go/testdata/script/goauth_git.txt

index 79e0d8b5e8f2f62e1e2c803e103cc43f69bea4a0..83c28d160c9d90ff148f5102b9cd22ced445e8e0 100644 (file)
@@ -128,7 +128,8 @@ func runGoAuth(client *http.Client, res *http.Response, url string) {
        // If no GOAUTH command provided a credential for the given url
        // and an error occurred, log the error.
        if cfg.BuildX && url != "" {
-               if ok := loadCredential(&http.Request{}, url); !ok && len(cmdErrs) > 0 {
+               req := &http.Request{Header: make(http.Header)}
+               if ok := loadCredential(req, url); !ok && len(cmdErrs) > 0 {
                        log.Printf("GOAUTH encountered errors for %s:", url)
                        for _, err := range cmdErrs {
                                log.Printf("  %v", err)
index 4fae39aaa710405cef96f73aa6a208f5d5a3eb5b..37c9b19a0458060e14ba90633b622ef157893b1c 100644 (file)
@@ -49,6 +49,8 @@ go get vcs-test.golang.org/auth/or401
 go mod tidy
 go list all
 stdout vcs-test.golang.org/auth/or404
+# With cached credentials, re-downloading in debug mode should succeed.
+go get -x vcs-test.golang.org/auth/or401
 
 # Clearing GOAUTH credentials should result in failures.
 env GOAUTH='off'