diff options
| -rw-r--r-- | env.go | 5 | ||||
| -rw-r--r-- | package.go | 16 |
2 files changed, 17 insertions, 4 deletions
@@ -1074,7 +1074,7 @@ func (env *Env) update(curPkg, newPkg *Package) (ok bool, err error) { fmt.Println("[ENV] update >>>", newPkg) } - if curPkg.IsEqual(newPkg) { + if curPkg.IsEqual(newPkg) || !newPkg.IsNewer(curPkg) { fmt.Println("[ENV] update >>> All package is up todate.") ok = true return @@ -1275,9 +1275,10 @@ func (env *Env) SyncAll() (err error) { return } - if pkg.Version == pkg.VersionNext { + if pkg.Version >= pkg.VersionNext { fmt.Printf("[ENV] SyncAll %s >>> No update.\n\n", pkg.ImportPath) + pkg.VersionNext = "" continue } @@ -110,8 +110,8 @@ func (pkg *Package) CompareVersion(newPkg *Package) (err error) { } // -// FetchLatestVersion will try to update the package and get the latest version (tag or -// commit). +// FetchLatestVersion will try to update the package and get the latest +// version (tag or commit). // func (pkg *Package) FetchLatestVersion() (err error) { switch pkg.vcsMode { @@ -210,6 +210,18 @@ func (pkg *Package) IsEqual(other *Package) bool { } // +// IsNewer will return true if current package is using tag and have newer +// version that other package. If current package is not using tag, it's +// always return true. +// +func (pkg *Package) IsNewer(older *Package) bool { + if !pkg.isTag { + return true + } + return pkg.Version >= older.Version +} + +// // Remove package installed binaries, archives, and source. // func (pkg *Package) Remove() (err error) { |
