window to show unapplied patches

This commit is contained in:
Jeff Carr 2025-03-23 08:47:34 -05:00
parent 682e06590f
commit 033e81bb22
1 changed files with 64 additions and 25 deletions

View File

@ -119,11 +119,39 @@ func makePatchsetsWin() *stdPatchsetTableWin {
all := me.psets.All() all := me.psets.All()
for all.Scan() { for all.Scan() {
pset := all.Next() pset := all.Next()
setNewCommitHash(pset) if pset.State != "new" {
log.Info("patchset already had state", pset.Name, pset.State)
continue
}
if setNewCommitHash(pset) {
// everything in this patchset is applied
pset.State = "APPLIED"
}
} }
savePatchsets() savePatchsets()
}) })
grid.NewButton("show pending patches", func() {
if me.psets == nil {
log.Info("No Patchsets loaded")
return
}
notdone := new(forgepb.Patches)
all := me.psets.All()
for all.Scan() {
pset := all.Next()
AddNotDonePatches(notdone, pset)
}
for patch := range notdone.IterAll() {
comment := cleanSubject(patch.Comment)
log.Info("new patch:", patch.NewHash, "commithash:", patch.CommitHash, patch.RepoNamespace, comment)
}
// savePatchsets()
makePatchesWin(notdone)
})
// make a box at the bottom of the window for the protobuf table // make a box at the bottom of the window for the protobuf table
dwin.box = dwin.win.Bottom.Box().SetProgName("TBOX") dwin.box = dwin.win.Bottom.Box().SetProgName("TBOX")
@ -293,7 +321,8 @@ func findCommitBySubject(subject string) (string, error) {
return "", fmt.Errorf("no commit found for subject: %s", subject) return "", fmt.Errorf("no commit found for subject: %s", subject)
} }
func setNewCommitHash(p *forgepb.Patchset) { func setNewCommitHash(p *forgepb.Patchset) bool {
var done bool = true
for patch := range p.Patches.IterAll() { for patch := range p.Patches.IterAll() {
// parts := strings.Fields(patch.Comment) // parts := strings.Fields(patch.Comment)
@ -309,6 +338,7 @@ func setNewCommitHash(p *forgepb.Patchset) {
log.Info("patch: newhash:", patch.NewHash, "commithash:", patch.CommitHash, patch.RepoNamespace, comment) log.Info("patch: newhash:", patch.NewHash, "commithash:", patch.CommitHash, patch.RepoNamespace, comment)
continue continue
} }
done = false
os.Chdir(repo.GetFullPath()) os.Chdir(repo.GetFullPath())
newhash, err := findCommitBySubject(comment) newhash, err := findCommitBySubject(comment)
if err != nil { if err != nil {
@ -317,29 +347,38 @@ func setNewCommitHash(p *forgepb.Patchset) {
} }
patch.NewHash = newhash patch.NewHash = newhash
log.Info("patch: found hash:", patch.CommitHash, newhash, patch.RepoNamespace, comment) log.Info("patch: found hash:", patch.CommitHash, newhash, patch.RepoNamespace, comment)
}
/* return done
repo := me.forge.FindByGoPath(patch.RepoNamespace) }
if repo == nil {
log.Info("couldn't find repo", patch.RepoNamespace) func AddNotDonePatches(notdone *forgepb.Patches, pset *forgepb.Patchset) {
bad = true for patch := range pset.Patches.IterAll() {
continue // parts := strings.Fields(patch.Comment)
}
if _, err := repo.GetHashName(patch.CommitHash); err == nil { repo := me.forge.FindByGoPath(patch.RepoNamespace)
// this patch has been applied if repo == nil {
patch.Applied = true log.Info("couldn't find repo", patch.RepoNamespace)
done = true notdone.Append(patch)
continue continue
} }
if name, err := repo.GetHashName(patch.StartHash); err == nil {
// it might be possible to apply this patch comment := cleanSubject(patch.Comment)
log.Info("patch may be good:", patch.RepoNamespace, name, patch.CommitHash, patch.Filename)
good = true if patch.NewHash != "na" {
} else { log.Info("already applied patch: newhash:", patch.NewHash, "commithash:", patch.CommitHash, patch.RepoNamespace, comment)
// probably screwed up git trees continue
log.Info("patch with unknown origin:", patch.RepoNamespace, name, err, patch.CommitHash, patch.Filename) }
bad = true os.Chdir(repo.GetFullPath())
} newhash, err := findCommitBySubject(comment)
*/ if err == nil {
patch.NewHash = newhash
log.Info("patch: found hash:", patch.CommitHash, newhash, patch.RepoNamespace, comment)
continue
}
// this patch has not been applied yet
log.Info("patch: not found hash:", patch.CommitHash, patch.RepoNamespace, comment, newhash, err)
notdone.Append(patch)
} }
} }