cmd/go/internal/modfetch/codehost: refactor gitRepo.loadRefs to be harder to misuse
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 <f3fadaedc813344da5ec13b41e26596889cc5baa@google.com>
Run-TryBot: Jay Conrod <f3fadaedc813344da5ec13b41e26596889cc5baa@google.com>
TryBot-Result: Go Bot <66cb808b70d30c07676d5e946fee83fd561249e5@golang.org>
Reviewed-by: Bryan C. Mills <1c8aad60184261ccede67f5c63a0d2a3bf3c9ff4@google.com>

golang/go,CAFxX/go,golang/go,nawawi/go,cloudflare/go,CAFxX/go,golang/go,golang/go,nawawi/go,nawawi/go,cloudflare/go,cloudflare/go,nawawi/go,nawawi/go,golang/go,cloudflare/go,nawawi/go,nawawi/go,nawawi/go,CAFxX/go,cloudflare/go,cloudflare/go,golang/go,cloudflare/go,golang/go,cloudflare/go,CAFxX/go,golang/go,CAFxX/go,CAFxX/go,CAFxX/go,CAFxX/go