diff options
| author | Shulhan <ms@kilabit.info> | 2018-11-01 00:01:54 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2018-11-01 00:01:54 +0700 |
| commit | e1993ddbadd8253f1fa65620b209b501ba70e44f (patch) | |
| tree | bd2d761266bac3988b2824029caa8a378a196ded | |
| parent | 20e98b127e16a40cf9f982cc44cc470ab73a8f9d (diff) | |
| download | beku-e1993ddbadd8253f1fa65620b209b501ba70e44f.tar.xz | |
env: check if new package version is greater than current version
| -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) { |
