Compare commits

..

No commits in common. "master" and "v0.25.18" have entirely different histories.

3 changed files with 83 additions and 74 deletions

View File

@ -101,80 +101,66 @@ func doPatch() error {
if argv.Patch.List != nil { if argv.Patch.List != nil {
var changed bool var changed bool
newpatches := new(forgepb.Set) newpatches := forgepb.NewPatches()
newpatches.Patches = forgepb.NewPatches()
for pset := range me.forge.Patchsets.IterAll() { for pset := range me.forge.Patchsets.IterAll() {
pset.PrintTable() log.Info(pset.Uuid)
for patch := range pset.Patches.IterAll() { for patch := range pset.Patches.IterAll() {
changed = true if setNewCommitHash(patch) {
if patch.NewHash == "" || patch.NewHash == "na" { changed = true
if newpatches.Patches.AppendByPatchId(patch) { }
log.Info("patchId added here", patch.PatchId) if patch.NewHash == "na" {
} else { newpatches.Append(patch)
log.Info("patchId already here", patch.PatchId) log.Info("apply this patch?")
}
} else {
if err := setNewCommitHash(patch); err != nil {
log.Infof("%s bad check on patch failure %v\n", patch.Filename, err)
return err
}
log.Info("newhash set already here", patch.PatchId, patch.NewHash)
} }
} }
/*
for patch := range pset.Patches.IterAll() {
if repo, ok := me.forge.IsPatchApplied(patch); ok {
log.Info("\tfound patch in repo", repo.Namespace, patch.Filename)
} else {
log.Info("\tdid not find patch", patch.CommitHash, patch.NewHash, patch.Filename)
}
}
*/
} }
if changed { if changed {
if err := me.forge.SavePatchsets(); err != nil { if err := me.forge.SavePatchsets(); err != nil {
log.Warn("savePatchsets() failed", err) log.Warn("savePatchsets() failed", err)
} }
} }
log.Info("NEW PATCHES TABLE") me.forge.Patchsets.PrintTable()
newpatches.PrintTable() if newpatches.Len() != 0 {
for patch := range newpatches.Patches.IterAll() { for patch := range newpatches.IterAll() {
if err := setNewCommitHash(patch); err == nil { log.Info("new patch:", patch.CommitHash, patch.NewHash, patch.Filename)
log.Info("newhash set already here", patch.PatchId, patch.NewHash) repo := me.forge.FindByGoPath(patch.Namespace)
continue if repo == nil {
} log.Info("\tCould not find namespace:", patch.Namespace)
log.Infof("%s is new\n", patch.Filename) continue
repo := me.forge.FindByGoPath(patch.Namespace) }
if repo == nil { if fhelp.QuestionUser("apply this patch?") {
log.Info("\tCould not find namespace:", patch.Namespace) newhash, err := applyAndTrackPatch(repo, patch)
continue log.Info("apply results:", newhash, err)
}
if fhelp.QuestionUser("apply this patch?") {
newhash, err := applyAndTrackPatch(repo, patch)
log.Info("apply results:", newhash, err)
}
}
return nil
/*
if newpatches.Len() != 0 {
for patch := range newpatches.IterAll() {
log.Info("new patch:", patch.CommitHash, patch.NewHash, patch.Filename)
repo := me.forge.FindByGoPath(patch.Namespace)
if repo == nil {
log.Info("\tCould not find namespace:", patch.Namespace)
continue
}
} }
return log.Errorf("patches need to be applied")
} }
return log.Errorf("patches need to be applied")
}
// return doPatchList() // return doPatchList()
applied := findApplied() applied := findApplied()
if applied == nil || applied.Len() == 0 { if applied == nil || applied.Len() == 0 {
log.Info("no patches have been appled to the devel branch yet") log.Info("no patches have been appled to the devel branch yet")
return nil
}
// for patch := range applied.IterAll() {
// log.Info("SEND APPLIED: newhash:", patch.NewHash, "commithash:", patch.CommitHash, "patch", patch.Namespace)
// }
newpb, _, err := applied.HttpPostVerbose(myServer(), "applied")
if err != nil {
return err
}
newpb.PrintTable()
return nil return nil
*/ }
// for patch := range applied.IterAll() {
// log.Info("SEND APPLIED: newhash:", patch.NewHash, "commithash:", patch.CommitHash, "patch", patch.Namespace)
// }
newpb, _, err := applied.HttpPostVerbose(myServer(), "applied")
if err != nil {
return err
}
newpb.PrintTable()
return nil
} }
// if nothing, show patches & dirty repos // if nothing, show patches & dirty repos

View File

@ -173,32 +173,52 @@ func findCommitBySubject(subject string) (string, error) {
} }
// returns true if PB changed // returns true if PB changed
func setNewCommitHash(patch *forgepb.Patch) error { func setNewCommitHash(patch *forgepb.Patch) bool {
// parts := strings.Fields(patch.Comment)
repo := me.forge.FindByGoPath(patch.Namespace) repo := me.forge.FindByGoPath(patch.Namespace)
if repo == nil { if repo == nil {
return log.Errorf("could not find repo %s", patch.Namespace) log.Info("could not find repo", patch.Namespace)
return false
} }
comment := cleanSubject(patch.Comment) comment := cleanSubject(patch.Comment)
if patch.NewHash == "" {
log.Info("init() new patch to 'na' ", patch.NewHash, "commithash:", patch.CommitHash, patch.Namespace, comment)
patch.NewHash = "na"
return true
}
os.Chdir(repo.GetFullPath()) os.Chdir(repo.GetFullPath())
newhash, err := findCommitBySubject(comment) newhash, err := findCommitBySubject(comment)
if err != nil { if err != nil {
return log.Errorf("patch: not found hash: %s %s %s %s %v", patch.CommitHash, patch.Namespace, comment, newhash, err) log.Info("patch: not found hash:", patch.CommitHash, patch.Namespace, comment, newhash, err)
return false
} }
if patch.NewHash == newhash {
patchId, err := repo.FindPatchId(newhash) // patch was already set
if err != nil { return false
return err }
if patch.NewHash != "na" {
log.Infof("patch: hash MISMATCH %s old=%s new=%s name=%s\n", patch.Namespace, patch.NewHash, newhash, comment)
return false
} }
patch.PatchId = patchId
patch.NewHash = newhash patch.NewHash = newhash
log.Info("patch: found hash:", patch.CommitHash, newhash, patch.Namespace, comment) log.Info("patch: found hash:", patch.CommitHash, newhash, patch.Namespace, comment)
return nil return true
} }
/*
func setNewCommitHashLoop(p *forgepb.Set) bool {
var done bool = true
for patch := range p.Patches.IterAll() {
setNewCommitHashLoop(patch)
}
return done
}
*/
func AddAllPatches(notdone *forgepb.Patches, pset *forgepb.Set, full bool) { func AddAllPatches(notdone *forgepb.Patches, pset *forgepb.Set, full bool) {
for patch := range pset.Patches.IterAll() { for patch := range pset.Patches.IterAll() {
comment := cleanSubject(patch.Comment) comment := cleanSubject(patch.Comment)
@ -231,7 +251,7 @@ func AddNotDonePatches(notdone *forgepb.Patches, pset *forgepb.Set, full bool) {
continue continue
} }
if patch.NewHash != "" { if patch.NewHash != "na" {
log.Info("already applied patch", patch.Namespace, ": newhash:", patch.NewHash, "commithash:", patch.CommitHash, comment) log.Info("already applied patch", patch.Namespace, ": newhash:", patch.NewHash, "commithash:", patch.CommitHash, comment)
continue continue
} }
@ -281,7 +301,7 @@ func findExpired() *forgepb.Patches {
continue continue
} }
if patch.NewHash != "" { if patch.NewHash != "na" {
log.Info("already applied patch", patch.Namespace, ": newhash:", patch.NewHash, "commithash:", patch.CommitHash, comment) log.Info("already applied patch", patch.Namespace, ": newhash:", patch.NewHash, "commithash:", patch.CommitHash, comment)
found.AppendByCommitHash(patch) // double check to ensure the commit hash isn't added twice found.AppendByCommitHash(patch) // double check to ensure the commit hash isn't added twice
continue continue

View File

@ -117,9 +117,12 @@ func applyPatchLabel(p *forgepb.Patch) string {
// log.Info("Could not figure out repo path", rn) // log.Info("Could not figure out repo path", rn)
return "" return ""
} }
if p.NewHash == "" { if p.NewHash == "na" {
return "git am" return "git am"
} }
if p.NewHash == "" {
return "new"
}
return "done" return "done"
} }