]> Cypherpunks repositories - gostls13.git/commit
cmd/go/internal/modfetch/codehost: refactor gitRepo.loadRefs to be harder to misuse
authorJay Conrod <jayconrod@google.com>
Wed, 28 Jul 2021 21:16:47 +0000 (14:16 -0700)
committerJay Conrod <jayconrod@google.com>
Mon, 16 Aug 2021 20:21:13 +0000 (20:21 +0000)
commit8d2066177dda53372469040e9bd18f836f121c58
tree102244df8765770f91a0d2d3d4fcb4b7b91535ab
parentec271687129dc8b263699b0b9d3abed71d8bd39d
cmd/go/internal/modfetch/codehost: refactor gitRepo.loadRefs to be harder to misuse

Previously, callers of loadRefs were expected to always
call via gitRepo.refsOnce.Do and check r.refsErr. This hasn't always
been the case.

This change makes loadRefs cache its own result with r.refsOnce and
return refs and refsErr. Callers can use it more like a normal
function.

CL 297950 is related. Previously, a commit like 0123456789ab could be
resolved to a v0.0.0 pseudo-version when tags couldn't be fetched, but
a shorter commit like 0123456 or a branch name like "master" couldn't
be resolved the same way. With this change, tags must be fetched
successfully ('git ls-remote' must succeed).

For #42751

Change-Id: I49c9346e6c72609ee4f8b10cfe1f69781e78457e
Reviewed-on: https://go-review.googlesource.com/c/go/+/338191
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
src/cmd/go/internal/modfetch/codehost/git.go