cmd/go/internal/modfetch/codehost: ignore incomplete semver tags in RecentTag

Fixes #31965

Change-Id: I2126903196b630c0bee2c022be1a818e0856ce3b
Reviewed-on: https://go-review.googlesource.com/c/go/+/176539
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
This commit is contained in:
Bryan C. Mills 2019-05-10 15:34:17 -04:00
parent 5f320f962b
commit 8d212c3ac3
1 changed files with 2 additions and 1 deletions

View File

@ -678,7 +678,8 @@ func (r *gitRepo) RecentTag(rev, prefix string) (tag string, err error) {
}
semtag := line[len(prefix):]
if semver.IsValid(semtag) {
// Consider only tags that are valid and complete (not just major.minor prefixes).
if c := semver.Canonical(semtag); c != "" && strings.HasPrefix(semtag, c) {
highest = semver.Max(highest, semtag)
}
}