]> xenbits.xensource.com Git - people/gdunlap/xsatool/commitdiff
global: Fix checking for new versions
authorGeorge Dunlap <george.dunlap@citrix.com>
Thu, 26 Jul 2018 15:39:07 +0000 (16:39 +0100)
committerGeorge Dunlap <george.dunlap@citrix.com>
Thu, 26 Jul 2018 15:39:07 +0000 (16:39 +0100)
The documentation claims that `xsatool global update` will check for
and initialize new versions.  But the code only does the check when
initializing a new global.meta.

Fix this by setting `limit` when global.meta already exists to the
most recent non-master version, and adding any version greater than
that version.

Signed-off-by: George Dunlap <george.dunlap@citrix.com>
global.go

index 7029b87d52ae91175c8d8e09f2d419e216d43001..24c4d847d20eb3a26aeb89f86ab95df2e2d1875d 100644 (file)
--- a/global.go
+++ b/global.go
@@ -42,6 +42,21 @@ func MainGlobalUpdate(unused *XSAMeta, args []string) int {
                sm.InitVersion(XenVersionMaster)
 
                init = true
+       } else {
+               // Find newest current non-Master version
+               for v := range sm.Versions {
+                       if v == XenVersionMaster {
+                               continue
+                       }
+                       if limit.Check() {
+                               if v.IsGreaterThan(limit) {
+                                       limit = v
+                               }
+                       } else {
+                               limit = v
+                       }
+                       
+               }
        }
 
        fmt.Printf("Getting Xen releases from tree...\n")
@@ -52,12 +67,8 @@ func MainGlobalUpdate(unused *XSAMeta, args []string) int {
        }
 
        for _, fv := range versions {
-               _, prs := sm.Versions[fv.XenVersion()]
-               if prs {
-                       continue
-               }
-
-               if init && fv.XenVersion().IsGreaterEqualThan(limit) {
+               if (init && fv.XenVersion().IsGreaterEqualThan(limit)) ||
+                       fv.XenVersion().IsGreaterThan(limit) {
                        sm.InitVersion(fv.XenVersion())
                } else {
                        fmt.Printf("Skipping version %v\n", fv)