making patch handling better
This commit is contained in:
parent
f82c9ee088
commit
888442708c
|
@ -6,6 +6,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
|
"go.wit.com/lib/cobol"
|
||||||
"go.wit.com/lib/gui/shell"
|
"go.wit.com/lib/gui/shell"
|
||||||
"go.wit.com/lib/protobuf/gitpb"
|
"go.wit.com/lib/protobuf/gitpb"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
|
@ -321,3 +322,35 @@ func (f *Forge) printForgedToTable(repo *gitpb.Repo, sizes []int) {
|
||||||
|
|
||||||
log.Info(start, end)
|
log.Info(start, end)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (psets *Patchsets) PrintTable() {
|
||||||
|
if psets == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
log.DaemonMode(true)
|
||||||
|
|
||||||
|
// print the header
|
||||||
|
args := []string{"commit hash", "what", "age", "cId", "partId", "", "", "", "", ""}
|
||||||
|
sizes := []int{36, 3, 3, 40, 80, 2, 2, 2, 2, 2}
|
||||||
|
log.Info(cobol.StandardTableSize10(sizes, args))
|
||||||
|
|
||||||
|
var countCONTENTS int
|
||||||
|
var countPARTS int
|
||||||
|
for x, pset := range psets.GetPatchsets() {
|
||||||
|
log.Info(pset.Uuid, pset.Name)
|
||||||
|
cId := log.Sprintf("%d", x)
|
||||||
|
countCONTENTS += 1
|
||||||
|
for i, p := range pset.Patches.GetPatches() {
|
||||||
|
var args []string
|
||||||
|
partId := log.Sprintf("%d", i)
|
||||||
|
|
||||||
|
_, fname := filepath.Split(p.GetFilename())
|
||||||
|
args = []string{p.CommitHash, cId, partId, fname, p.GetNamespace(), "", "", "", "", ""}
|
||||||
|
|
||||||
|
start := cobol.StandardTableSize10(sizes, args)
|
||||||
|
log.Info(start)
|
||||||
|
countPARTS += 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.Infof("Total Contents (%d) Parts (%d)\n", countCONTENTS, countPARTS)
|
||||||
|
}
|
||||||
|
|
|
@ -6,13 +6,14 @@ import (
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (f *Forge) GetPatchesets() (*Patchsets, error) {
|
// retrieves current patches from forge
|
||||||
|
func (f *Forge) GetPatches() error {
|
||||||
url := f.forgeURL + "GetPatchsets"
|
url := f.forgeURL + "GetPatchsets"
|
||||||
log.Info("GetPatchsets() url", url)
|
log.Info("GetPatchsets() url", url)
|
||||||
body, err := f.HttpPost(url, nil)
|
body, err := f.HttpPost(url, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Info("httpPost() failed:", err)
|
log.Info("httpPost() failed:", err)
|
||||||
return nil, err
|
return err
|
||||||
}
|
}
|
||||||
log.Info("GetPatchets() len(body)", len(body))
|
log.Info("GetPatchets() len(body)", len(body))
|
||||||
var psets *Patchsets
|
var psets *Patchsets
|
||||||
|
@ -20,7 +21,7 @@ func (f *Forge) GetPatchesets() (*Patchsets, error) {
|
||||||
err = psets.Unmarshal(body)
|
err = psets.Unmarshal(body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Info("Unmarshal failed", err)
|
log.Info("Unmarshal failed", err)
|
||||||
return nil, err
|
return err
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
filename := filepath.Join("/tmp", pbfile)
|
filename := filepath.Join("/tmp", pbfile)
|
||||||
|
@ -28,5 +29,31 @@ func (f *Forge) GetPatchesets() (*Patchsets, error) {
|
||||||
f.Write(body)
|
f.Write(body)
|
||||||
f.Close()
|
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()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue