-
Notifications
You must be signed in to change notification settings - Fork 17.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/go: go mod download -json should add 'Latest bool' #32239
Comments
It seems to me that that information can already be resolved from the Specifically, we can examine the
That leaves open the question of what to do if the proxy sees a pseudo-version or prerelease tag derived from something newer than |
This is already too much of complexity to implement correctly outside |
You mean like You could easily skip the “pseudo-version derived from a release version after latest” part, in which case you get: if semver.Prerelease(m.Version) == "" && semver.Max(latest, m.Version) == m.Version {
// Update latest.
[…]
} For the “derived from a release version after” case, perhaps we could add a |
@bcmills, do you mean the cached latest version in the proxy's database by 'latest' in your code snippet? (again, we are looking for a solution that avoids extra run of 'go list -versions' or 'go mod download module@latest' - because we are running each command in an isolated sandbox currently). I think the pseudo-version can be newer than the actual latest (in the origin) if the pseudo-version was derived from a development branch or non-default branch. |
Yes. |
Yes: the pseudo-version is calculated based on the highest tag from a parent commit, which may be the However, note that every pseudo-version is also semantically a prerelease version: hence the |
A bit more context behind this issue: we are investigating if it's possible to determine (without extra list query) whether the newly downloaded module version from |
Ah, ok! In that case, I think you need only one more function, if semver.Max(latest, m.Version) == m.Version {
allowed := true
if module.IsPseudoVersion(m.Version) {
for _, v := range cachedVersions {
if !module.IsPseudoVersion(v) {
allowed = false
break
}
}
} else if semver.Prerelease(m.Version) != "" {
onlyPseudoVersions := true
for _, v := range cachedVersions {
if semver.Prerelease(m.Version) == "" {
allowed = false
break
}
}
}
if allowed {
// Update latest.
[…]
}
} That's admittedly a fair amount of code, but it's comparable to what we would have to add to |
I don't believe you can derive latest-ness from the pseudo-version strings themselves. Whether something is latest depends, for Git, on what master is set to. Master can be changed arbitrarily in ways that don't respect semantic version ordering. We should provide |
I think this will require a little bit of thought and then very little actual coding. If that's the case, it would be good to get this into Go 1.13 so that proxies can use it before 1.14 comes out. |
Change https://golang.org/cl/183841 mentions this issue: |
go get <modulepath>@<version>
triggersGET $GOPROXY/<modulepath>/@v/<version>.{info, mod, zip}
queries when it talks with GOPROXY.When it's the very first time the module proxy sees the version, the proxy may want to update its database and, if necessary, serve the newest version as the
latest
version of the module. Module owners may utilize this to tell the module proxy or Go Module Mirror as soon as the version becomes available in the origin.But the proxy need to be careful because the the may be a commit or branch, and there is no guarantee that the newly fetched version is suitable as the
latest
version. The proxy may perform extra go list queries itself for every new version it observes, but it would be nice if the 'go mod download' command designed for the proxy provides this info in its output.@rsc @bcmills @jayconrod @katiehockman @heschik
The text was updated successfully, but these errors were encountered: