summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--windowNewPatchsets.go89
1 files changed, 64 insertions, 25 deletions
diff --git a/windowNewPatchsets.go b/windowNewPatchsets.go
index 92f5938..36ee7ba 100644
--- a/windowNewPatchsets.go
+++ b/windowNewPatchsets.go
@@ -119,11 +119,39 @@ func makePatchsetsWin() *stdPatchsetTableWin {
all := me.psets.All()
for all.Scan() {
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()
})
+ 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
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)
}
-func setNewCommitHash(p *forgepb.Patchset) {
+func setNewCommitHash(p *forgepb.Patchset) bool {
+ var done bool = true
for patch := range p.Patches.IterAll() {
// 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)
continue
}
+ done = false
os.Chdir(repo.GetFullPath())
newhash, err := findCommitBySubject(comment)
if err != nil {
@@ -317,29 +347,38 @@ func setNewCommitHash(p *forgepb.Patchset) {
}
patch.NewHash = newhash
log.Info("patch: found hash:", patch.CommitHash, newhash, patch.RepoNamespace, comment)
+ }
- /*
- repo := me.forge.FindByGoPath(patch.RepoNamespace)
- if repo == nil {
- log.Info("couldn't find repo", patch.RepoNamespace)
- bad = true
- continue
- }
- if _, err := repo.GetHashName(patch.CommitHash); err == nil {
- // this patch has been applied
- patch.Applied = true
- done = true
- continue
- }
- if name, err := repo.GetHashName(patch.StartHash); err == nil {
- // it might be possible to apply this patch
- log.Info("patch may be good:", patch.RepoNamespace, name, patch.CommitHash, patch.Filename)
- good = true
- } else {
- // probably screwed up git trees
- log.Info("patch with unknown origin:", patch.RepoNamespace, name, err, patch.CommitHash, patch.Filename)
- bad = true
- }
- */
+ return done
+}
+
+func AddNotDonePatches(notdone *forgepb.Patches, pset *forgepb.Patchset) {
+ for patch := range pset.Patches.IterAll() {
+ // parts := strings.Fields(patch.Comment)
+
+ repo := me.forge.FindByGoPath(patch.RepoNamespace)
+ if repo == nil {
+ log.Info("couldn't find repo", patch.RepoNamespace)
+ notdone.Append(patch)
+ continue
+ }
+
+ comment := cleanSubject(patch.Comment)
+
+ if patch.NewHash != "na" {
+ log.Info("already applied patch: newhash:", patch.NewHash, "commithash:", patch.CommitHash, patch.RepoNamespace, comment)
+ continue
+ }
+ 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)
}
}