#8 new flag UpMajor.

This commit is contained in:
Gorbunov Kirill Andreevich
2024-03-17 15:41:25 +03:00
parent 3a60ffbf91
commit 974c685136
5 changed files with 84 additions and 14 deletions

View File

@@ -250,7 +250,8 @@ type UpdateOptions struct {
Modules []module.Version
Pre bool
Cached bool
Major bool
Major bool // Major true compare only major
UpMajor bool // UpMajor module up with major
}
// Updates finds updates for a set of specified modules.
@@ -276,13 +277,13 @@ func Updates(opt UpdateOptions) {
ch <- Update{Module: m, Err: err}
return nil
}
prefix, ok := ModMajor(mod.Path)
major := semver.Major(m.Version)
var v string
switch ok {
switch opt.UpMajor {
case true:
v = mod.MaxVersion(prefix, opt.Pre)
default:
v = mod.MaxVersion("", opt.Pre)
case false:
v = mod.MaxVersion(major, opt.Pre)
}
if IsNewerVersion(m.Version, v, opt.Major) {
ch <- Update{Module: m, Version: v}