[go] cmd/go: fix unexpected "v1.x.y is not a tag" after update to Go 1.16.14

100 views
Skip to first unread message

Gopher Robot (Gerrit)

unread,
Jun 28, 2022, 3:45:10 PM6/28/22
to do hi, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Dmitri Shuralyov, Dmitri Shuralyov, David Chase, Bryan Mills, Meng Zhuo, Michael Matloob, Russ Cox, Ian Lance Taylor, golang-co...@googlegroups.com

Gopher Robot submitted this change.

View Change


Approvals: Bryan Mills: Looks good to me, approved; Run TryBots; Automatically submit change Gopher Robot: TryBots succeeded Dmitri Shuralyov: Looks good to me, but someone else must approve Dmitri Shuralyov: Looks good to me, approved David Chase: Looks good to me, but someone else must approve
cmd/go: pass --no-decorate when listing git tags for a commit

This avoids a parse error when the user's global .gitconfig sets
log.decorate to true.

Fixes #51312.

Change-Id: Ic47b0f604c0c3a404ec50d6e09f4e138045ac2f2
Reviewed-on: https://go-review.googlesource.com/c/go/+/387835
Run-TryBot: Bryan Mills <bcm...@google.com>
Auto-Submit: Bryan Mills <bcm...@google.com>
Reviewed-by: Bryan Mills <bcm...@google.com>
TryBot-Result: Gopher Robot <go...@golang.org>
Reviewed-by: Dmitri Shuralyov <dmit...@golang.org>
Reviewed-by: David Chase <drc...@google.com>
Reviewed-by: Dmitri Shuralyov <dmit...@google.com>
---
M src/cmd/go/internal/modfetch/codehost/git.go
A src/cmd/go/testdata/script/mod_download_git_decorate_full.txt
2 files changed, 51 insertions(+), 1 deletion(-)

diff --git a/src/cmd/go/internal/modfetch/codehost/git.go b/src/cmd/go/internal/modfetch/codehost/git.go
index 853d43b..034abf3 100644
--- a/src/cmd/go/internal/modfetch/codehost/git.go
+++ b/src/cmd/go/internal/modfetch/codehost/git.go
@@ -447,7 +447,7 @@
// statLocal returns a RevInfo describing rev in the local git repository.
// It uses version as info.Version.
func (r *gitRepo) statLocal(version, rev string) (*RevInfo, error) {
- out, err := Run(r.dir, "git", "-c", "log.showsignature=false", "log", "-n1", "--format=format:%H %ct %D", rev, "--")
+ out, err := Run(r.dir, "git", "-c", "log.showsignature=false", "log", "--no-decorate", "-n1", "--format=format:%H %ct %D", rev, "--")
if err != nil {
return nil, &UnknownRevisionError{Rev: rev}
}
diff --git a/src/cmd/go/testdata/script/mod_download_git_decorate_full.txt b/src/cmd/go/testdata/script/mod_download_git_decorate_full.txt
new file mode 100644
index 0000000..3b19acc
--- /dev/null
+++ b/src/cmd/go/testdata/script/mod_download_git_decorate_full.txt
@@ -0,0 +1,28 @@
+env GO111MODULE=on
+
+[!net] skip
+[!exec:git] skip
+
+env GOPROXY=direct
+env HOME=$WORK/home/gopher
+
+
+go env GOPROXY
+stdout 'direct'
+
+exec git config --get log.decorate
+stdout 'full'
+
+# Test that Git log with user's global config '~/gitconfig' has log.decorate=full
+# go mod download has an error 'v1.x.y is not a tag'
+# with go1.16.14:
+# `go1.16.14 list -m vcs-test.golang.org/git/gitrep...@v1.2.3`
+# will output with error:
+# go list -m: vcs-test.golang.org/git/gitrep...@v1.2.3: invalid version: unknown revision v1.2.3
+# See golang/go#51312.
+go list -m vcs-test.golang.org/git/gitrep...@v1.2.3
+stdout 'vcs-test.golang.org/git/gitrepo1.git v1.2.3'
+
+-- $WORK/home/gopher/.gitconfig --
+[log]
+ decorate = full
\ No newline at end of file

To view, visit change 387835. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: Ic47b0f604c0c3a404ec50d6e09f4e138045ac2f2
Gerrit-Change-Number: 387835
Gerrit-PatchSet: 12
Gerrit-Owner: do hi <duv...@gmail.com>
Gerrit-Reviewer: Bryan Mills <bcm...@google.com>
Gerrit-Reviewer: David Chase <drc...@google.com>
Gerrit-Reviewer: Dmitri Shuralyov <dmit...@golang.org>
Gerrit-Reviewer: Dmitri Shuralyov <dmit...@google.com>
Gerrit-Reviewer: Gopher Robot <go...@golang.org>
Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
Gerrit-CC: Ian Lance Taylor <ia...@golang.org>
Gerrit-CC: Meng Zhuo <m...@golangcn.org>
Gerrit-CC: Russ Cox <r...@golang.org>
Gerrit-MessageType: merged
Reply all
Reply to author
Forward
0 new messages