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 both older and new versions of fossil, fossilParseStat will now check for either version of the prefix
when attempting to find the line containing the hash of the desired revision.

Fixes https://github.com/golang/go/issues/42323
This commit is contained in:
Curtis La Graff 2020-11-01 14:14:16 -05:00 committed by clagraff
parent bff4d99637
commit f4e6652307

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)