aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/internal/modload/build.go
diff options
context:
space:
mode:
authorPontus Leitzler <leitzler@gmail.com>2019-04-29 09:50:53 +0000
committerJay Conrod <jayconrod@google.com>2019-05-02 14:47:22 +0000
commitf03b3331c74ae45f0a5053287a26dd522f89f462 (patch)
tree4471f3d495ade0873771589c3b9acd88b43f2892 /src/cmd/go/internal/modload/build.go
parente4c0e9df8b328395570948f1b3fa4dc3235432f0 (diff)
downloadgo-f03b3331c74ae45f0a5053287a26dd522f89f462.tar.gz
go-f03b3331c74ae45f0a5053287a26dd522f89f462.zip
cmd/go/internal/modload: make 'list -u' consider current pseudoversion
As pointed out by thepudds in #30634, the 'list -u' documentation states that the current version should be considered for upgrade: The -u flag adds information about available upgrades. When the latest version of a given module is newer than the current one, list -u sets the Module's Update field to information about the newer module. In go 1.12.4 (and current tip), an older version will be suggested as upgrade to a newer pseudo version. Updates: #30634 Change-Id: If2c8887198884b8e7ccb3a604908065aa1f1878a Reviewed-on: https://go-review.googlesource.com/c/go/+/174206 Run-TryBot: Jay Conrod <jayconrod@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com>
Diffstat (limited to 'src/cmd/go/internal/modload/build.go')
-rw-r--r--src/cmd/go/internal/modload/build.go17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/cmd/go/internal/modload/build.go b/src/cmd/go/internal/modload/build.go
index a41b176ccd..66a0a75d96 100644
--- a/src/cmd/go/internal/modload/build.go
+++ b/src/cmd/go/internal/modload/build.go
@@ -12,6 +12,7 @@ import (
"cmd/go/internal/modinfo"
"cmd/go/internal/module"
"cmd/go/internal/search"
+ "cmd/go/internal/semver"
"encoding/hex"
"fmt"
"internal/goroot"
@@ -74,13 +75,15 @@ func ModuleInfo(path string) *modinfo.ModulePublic {
// addUpdate fills in m.Update if an updated version is available.
func addUpdate(m *modinfo.ModulePublic) {
- if m.Version != "" {
- if info, err := Query(m.Path, "latest", Allowed); err == nil && info.Version != m.Version {
- m.Update = &modinfo.ModulePublic{
- Path: m.Path,
- Version: info.Version,
- Time: &info.Time,
- }
+ if m.Version == "" {
+ return
+ }
+
+ if info, err := Query(m.Path, "latest", Allowed); err == nil && semver.Compare(info.Version, m.Version) > 0 {
+ m.Update = &modinfo.ModulePublic{
+ Path: m.Path,
+ Version: info.Version,
+ Time: &info.Time,
}
}
}