append patches to local patches file
This commit is contained in:
parent
50351298b6
commit
d6cd7fc88f
|
@ -330,8 +330,8 @@ func (psets *Patchsets) PrintTable() {
|
||||||
log.DaemonMode(true)
|
log.DaemonMode(true)
|
||||||
|
|
||||||
// print the header
|
// print the header
|
||||||
args := []string{"commit hash", "", "", "name", "Repo Namespace", "", "", "", "", ""}
|
args := []string{"commit hash", "new hash", "", "", "name", "Repo Namespace", "", "", "", "", ""}
|
||||||
sizes := []int{36, 3, 3, 40, 80, 2, 2, 2, 2, 2}
|
sizes := []int{12, 12, 3, 3, 40, 80, 2, 2, 2, 2}
|
||||||
log.Info(cobol.StandardTableSize10(sizes, args))
|
log.Info(cobol.StandardTableSize10(sizes, args))
|
||||||
|
|
||||||
var countCONTENTS int
|
var countCONTENTS int
|
||||||
|
@ -345,7 +345,7 @@ func (psets *Patchsets) PrintTable() {
|
||||||
partId := log.Sprintf("%d", i)
|
partId := log.Sprintf("%d", i)
|
||||||
|
|
||||||
_, fname := filepath.Split(p.GetFilename())
|
_, fname := filepath.Split(p.GetFilename())
|
||||||
args = []string{p.CommitHash, cId, partId, fname, p.GetNamespace(), "", "", "", "", ""}
|
args = []string{p.CommitHash, p.NewHash, cId, partId, fname, p.GetNamespace(), "", "", "", "", ""}
|
||||||
|
|
||||||
start := cobol.StandardTableSize10(sizes, args)
|
start := cobol.StandardTableSize10(sizes, args)
|
||||||
log.Info(start)
|
log.Info(start)
|
||||||
|
|
|
@ -23,12 +23,6 @@ func (f *Forge) GetPatches() error {
|
||||||
log.Info("Unmarshal failed", err)
|
log.Info("Unmarshal failed", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
filename := filepath.Join("/tmp", pbfile)
|
|
||||||
f, _ := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
|
|
||||||
f.Write(body)
|
|
||||||
f.Close()
|
|
||||||
*/
|
|
||||||
psets.PrintTable()
|
psets.PrintTable()
|
||||||
f.loadUpstreamPatchsets(psets)
|
f.loadUpstreamPatchsets(psets)
|
||||||
return nil
|
return nil
|
||||||
|
@ -40,6 +34,7 @@ func (f *Forge) loadUpstreamPatchsets(psets *Patchsets) {
|
||||||
for all.Scan() {
|
for all.Scan() {
|
||||||
pset := all.Next()
|
pset := all.Next()
|
||||||
found := f.Patchsets.FindByUuid(pset.Uuid)
|
found := f.Patchsets.FindByUuid(pset.Uuid)
|
||||||
|
author := log.Sprintf("Author: %s <%s>", found.GitAuthorName, found.GitAuthorEmail)
|
||||||
if found == nil {
|
if found == nil {
|
||||||
log.Info("new patchset", pset.Name, pset.Uuid)
|
log.Info("new patchset", pset.Name, pset.Uuid)
|
||||||
pset.State = "new"
|
pset.State = "new"
|
||||||
|
@ -52,13 +47,27 @@ func (f *Forge) loadUpstreamPatchsets(psets *Patchsets) {
|
||||||
log.Warn("OH NO! f.Patchsets == nil")
|
log.Warn("OH NO! f.Patchsets == nil")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
log.Warn("appending pset", pset.Uuid, pset.State, pset.Name)
|
||||||
f.Patchsets.Append(pset)
|
f.Patchsets.Append(pset)
|
||||||
} else {
|
continue
|
||||||
log.Info("patchset already on disk", found.Name, found.State)
|
}
|
||||||
pset.State = found.State
|
log.Info("EXAMINE PSET", pset.Name, pset.Uuid, pset.Patches.Len())
|
||||||
if pset.State == "" {
|
for _, patch := range pset.Patches.Patches {
|
||||||
pset.State = "new"
|
// log.Info("\tnew patch:", i, patch.CommitHash, patch.Namespace)
|
||||||
|
if f.findPatch(patch) {
|
||||||
|
// log.Info("\talready found!!!!!!!", pset.Uuid, patch.Namespace)
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
|
if err := f.addRandomPatch(patch); err == nil {
|
||||||
|
log.Info("\tnew patch added:", patch.CommitHash, found.Name, found.Comment, author)
|
||||||
|
foundnew = true
|
||||||
|
} else {
|
||||||
|
log.Info("\tnew patch failed:", patch.CommitHash, found.Name, found.Comment, author, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pset.State = found.State
|
||||||
|
if pset.State == "" {
|
||||||
|
pset.State = "new"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if foundnew {
|
if foundnew {
|
||||||
|
|
|
@ -84,26 +84,30 @@ func (pb *Patchset) ShowPatchsets() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// adds a patchset or just the patches
|
// adds a patchset or just the patches
|
||||||
func (f *Forge) AddPatchset(pb *Patchset) {
|
func (f *Forge) AddPatchset(pb *Patchset) bool {
|
||||||
|
var changed bool
|
||||||
// if the name of the patchset is "forge auto commit"
|
// if the name of the patchset is "forge auto commit"
|
||||||
// then just add all the patches
|
// then just add all the patches
|
||||||
if pb.Name == "forge auto commit" {
|
if pb.Name == "forge auto commit" {
|
||||||
author := "Author: " + pb.GitAuthorName
|
author := "Author: " + pb.GitAuthorName
|
||||||
author += " <" + pb.GitAuthorEmail + ">"
|
author += " <" + pb.GitAuthorEmail + ">"
|
||||||
|
|
||||||
// author := "Author: " + os.Getenv("GIT_AUTHOR_NAME")
|
|
||||||
// author += " <" + os.Getenv("GIT_AUTHOR_EMAIL") + ">"
|
|
||||||
fmt.Println(pb.Name, pb.Comment, author)
|
fmt.Println(pb.Name, pb.Comment, author)
|
||||||
for _, patch := range pb.Patches.Patches {
|
for _, patch := range pb.Patches.Patches {
|
||||||
// log.Info("\tnew patch:", i, patch.CommitHash, patch.Namespace)
|
// log.Info("\tnew patch:", i, patch.CommitHash, patch.Namespace)
|
||||||
if f.findPatch(patch) {
|
if f.findPatch(patch) {
|
||||||
// log.Info("\talready found!!!!!!!", pset.Uuid, patch.Namespace)
|
// log.Info("\talready found!!!!!!!", pset.Uuid, patch.Namespace)
|
||||||
} else {
|
} else {
|
||||||
log.Info("\tnew patch:", pb.Name, pb.Comment, author)
|
if err := f.addRandomPatch(patch); err == nil {
|
||||||
f.addRandomPatch(patch)
|
log.Info("\tnew patch added:", patch.CommitHash, pb.Name, pb.Comment, author)
|
||||||
|
changed = true
|
||||||
|
} else {
|
||||||
|
log.Info("\tnew patch failed:", patch.CommitHash, pb.Name, pb.Comment, author, err)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
return changed
|
||||||
}
|
}
|
||||||
|
|
||||||
// if you got here, this patchset was submitted with a name
|
// if you got here, this patchset was submitted with a name
|
||||||
|
@ -112,7 +116,8 @@ func (f *Forge) AddPatchset(pb *Patchset) {
|
||||||
for pset := range f.Patchsets.IterAll() {
|
for pset := range f.Patchsets.IterAll() {
|
||||||
if pset.Uuid == pb.Uuid {
|
if pset.Uuid == pb.Uuid {
|
||||||
log.Info("ALREADY ADDED", pset.Uuid, pset.Name)
|
log.Info("ALREADY ADDED", pset.Uuid, pset.Name)
|
||||||
return
|
return false
|
||||||
|
} else {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,6 +127,7 @@ func (f *Forge) AddPatchset(pb *Patchset) {
|
||||||
if newpb != nil {
|
if newpb != nil {
|
||||||
f.Patchsets.Patchsets = append(f.Patchsets.Patchsets, newpb)
|
f.Patchsets.Patchsets = append(f.Patchsets.Patchsets, newpb)
|
||||||
}
|
}
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Forge) findAutoPatchset() *Patchset {
|
func (f *Forge) findAutoPatchset() *Patchset {
|
||||||
|
|
Loading…
Reference in New Issue