diff options
Diffstat (limited to 'patchset.Get.go')
| -rw-r--r-- | patchset.Get.go | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/patchset.Get.go b/patchset.Get.go index 4ad3c48..91d3bdd 100644 --- a/patchset.Get.go +++ b/patchset.Get.go @@ -6,13 +6,14 @@ import ( "go.wit.com/log" ) -func (f *Forge) GetPatchesets() (*Patchsets, error) { +// retrieves current patches from forge +func (f *Forge) GetPatches() error { url := f.forgeURL + "GetPatchsets" log.Info("GetPatchsets() url", url) body, err := f.HttpPost(url, nil) if err != nil { log.Info("httpPost() failed:", err) - return nil, err + return err } log.Info("GetPatchets() len(body)", len(body)) var psets *Patchsets @@ -20,7 +21,7 @@ func (f *Forge) GetPatchesets() (*Patchsets, error) { err = psets.Unmarshal(body) if err != nil { log.Info("Unmarshal failed", err) - return nil, err + return err } /* filename := filepath.Join("/tmp", pbfile) @@ -28,5 +29,31 @@ func (f *Forge) GetPatchesets() (*Patchsets, error) { f.Write(body) f.Close() */ - return psets, nil + psets.PrintTable() + f.loadUpstreamPatchsets(psets) + return nil +} + +func (f *Forge) loadUpstreamPatchsets(psets *Patchsets) { + var foundnew bool + all := psets.All() + for all.Scan() { + pset := all.Next() + found := f.Patchsets.FindByUuid(pset.Uuid) + if found == nil { + log.Info("new patchset", pset.Name, pset.Uuid) + pset.State = "new" + foundnew = true + } else { + log.Info("patchset already on disk", found.Name, found.State) + pset.State = found.State + if pset.State == "" { + pset.State = "new" + } + } + } + if foundnew { + log.Info("should save these here") + f.SavePatchsets() + } } |
