1
0
mirror of https://github.com/golang/go synced 2024-11-17 08:14:48 -07:00

cmd/go/internal/modfetch/codehost: add support for new fossil info hash prefix

A recent update of the Fossil SCM application changes
the line prefix when the fossil info command is used.
Instead of the revision hash starting with "uuid:", it has been
changed to "hash:".

Fossil check-in introducing this change:

https://fossil-scm.org/home/info/8ad5e4690854a81a

To support older and new versions, fossilParseStat will
now check for either version of the prefix when attempting
to find the line containing the hash of the desired revision.

Fixes #42323

Change-Id: I6eff49f9989b37b295322a8569e222a1fd02f6e3
GitHub-Last-Rev: f4e6652307
GitHub-Pull-Request: golang/go#42324
Reviewed-on: https://go-review.googlesource.com/c/go/+/267080
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Trust: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
This commit is contained in:
Curtis La Graff 2020-11-03 20:26:17 +00:00 committed by Bryan C. Mills
parent 594b4a3bfe
commit 3a1d84b393
2 changed files with 27 additions and 1 deletions

View File

@ -568,7 +568,7 @@ func bzrParseStat(rev, out string) (*RevInfo, error) {
func fossilParseStat(rev, out string) (*RevInfo, error) {
for _, line := range strings.Split(out, "\n") {
if strings.HasPrefix(line, "uuid:") {
if strings.HasPrefix(line, "uuid:") || strings.HasPrefix(line, "hash:") {
f := strings.Fields(line)
if len(f) != 5 || len(f[1]) != 40 || f[4] != "UTC" {
return nil, vcsErrorf("unexpected response from fossil info: %q", line)

View File

@ -0,0 +1,26 @@
[!net] skip
[!exec:fossil] skip
# Regression test for 'go get' to ensure repositories
# provided by fossil v2.12 and up are able to be fetched
# and parsed correctly.
# Verifies golang.org/issue/42323.
env GO111MODULE=on
env GOPROXY=direct
env GOSUMDB=off
# 'go get' for the fossil repo will fail if fossil
# is unable to determine your fossil user. Easiest
# way to set it for use by 'go get' is specifying
# a any non-empty $USER; the value doesn't otherwise matter.
env USER=fossiluser
# Attempting to get the latest version of a fossil repo.
go get vcs-test.golang.org/fossil/hello.fossil
! stderr 'unexpected response from fossil info'
grep 'vcs-test.golang.org/fossil/hello.fossil' go.mod
-- go.mod --
module x