Skip to content

Commit

Permalink
cmd/go: accept @hash/branch in mod download
Browse files Browse the repository at this point in the history
Go get in mod-enabled packages lets you do go get "pkg@<hash>" or "pkg@<branch>".
Go internally will switch the hash or branch into a pseudo version.
Go mod download should do the same. The bug lied in the fact that the disk cache
was not being written when Go converted the hash/branch into a pseduo version.

Fixes golang#27947

Change-Id: Ib5b376c65406173c3cd8739254b37a919dff8e8f
  • Loading branch information
marwan-at-work committed Nov 5, 2018
1 parent 8256bcd commit e0227ae
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/cmd/go/internal/modfetch/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,18 @@ func (r *cachingRepo) Stat(rev string) (*RevInfo, error) {
}
info, err = r.r.Stat(rev)
if err == nil {
if err := writeDiskStat(file, info); err != nil {
fmt.Fprintf(os.Stderr, "go: writing stat cache: %v\n", err)
}
// If we resolved, say, 1234abcde to v0.0.0-20180604122334-1234abcdef78,
// then save the information under the proper version, for future use.
if info.Version != rev {
file, _, _ = readDiskStat(r.path, info.Version)
r.cache.Do("stat:"+info.Version, func() interface{} {
return cachedInfo{info, err}
})
}

if err := writeDiskStat(file, info); err != nil {
fmt.Fprintf(os.Stderr, "go: writing stat cache: %v\n", err)
}
}
return cachedInfo{info, err}
}).(cachedInfo)
Expand Down

0 comments on commit e0227ae

Please sign in to comment.