]> Cypherpunks repositories - gostls13.git/commit
cmd/go/internal/modfetch/codehost: fix pseudoversions for non-semver tags and tags...
authorPontus Leitzler <leitzler@gmail.com>
Fri, 26 Apr 2019 20:38:49 +0000 (20:38 +0000)
committerJay Conrod <jayconrod@google.com>
Wed, 1 May 2019 16:33:17 +0000 (16:33 +0000)
commitcbe2b14d5072dde739e5bfda7e5b4405412464ec
tree3d2587729171996528d8609a8a0459221b341d28
parente56c73f17b49793f9c57c0706344afafbec726d1
cmd/go/internal/modfetch/codehost: fix pseudoversions for non-semver tags and tags on other branches

Pseudoversion determination depends in part on the results from gitRepo.RecentTag, which currently invokes:

git describe --first-parent --always --abbrev=0 --match <prefix>v[0-9]*.[0-9]*.[0-9]* --tags <rev>

The comment at https://github.com/golang/go/issues/27171#issuecomment-470134255 describes some problems with the current approach.

One problem is Docker and other repos can have tags that are not valid semver tags but that still match a glob pattern of v[0-9]*.[0-9]*.[0-9]* which are found by 'git describe' but then rejected by cmd/go, and hence those repos currently can end up with v0.0.0 pseudoversions instead of finding a proper semver tag to use as input to building a pseudoversion  (when then causes problems when the v0.0.0 pseudoversion is fed into MVS). An example problematic tag is a date-based tag such as 'v18.06.16', which matches the glob pattern, but is not a valid semver tag (due to the leading 0 in '06').

Issues #31673, #31287, and #27171 also describe problems where the '--first-parent' argument to 'git describe' cause the current approach to miss relevant semver tags that were created on a separate branch and then subsequently merged to master.

In #27171, Bryan described the base tag that is supposed to be used for pseudoversions as:

"It is intended to be the semantically-latest tag that appears on any commit that is a (transitive) parent of the commit with the given hash, regardless of branches. (The pseudo-version is supposed to sort after every version — tagged or otherwise — that came before it, but before the next tag that a human might plausibly want to apply to the branch.)"

This CL solves the glob problem and tags-on-other-branches problem more directly than the current approach: this CL gets the full list of tags that have been merged into the specific revision of interest, and then sorts and filters the results in cmd/go to select the semantically-latest valid semver tag.

Fixes #31673
Fixes #31287
Updates #27171

Change-Id: I7c3e6b46b2b21dd60562cf2893b6bd2afaae61d5
Reviewed-on: https://go-review.googlesource.com/c/go/+/174061
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
src/cmd/go/internal/modfetch/codehost/git.go
src/cmd/go/testdata/script/mod_get_pseudo_other_branch.txt [new file with mode: 0644]
src/cmd/go/testdata/script/mod_get_pseudo_prefix.txt [new file with mode: 0644]