summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-03-22 21:37:45 -0500
committerJeff Carr <[email protected]>2025-03-22 21:37:45 -0500
commitdd2f7ed01df0991f2d20669fbbd41a1c6d407805 (patch)
treec749a7b843ca0959ebcd3eeef53a331ef8292223
parent205b1fe1edb5424f23a1b36f9e39df14765ff5af (diff)
list branches
-rw-r--r--windowNewPatchsets.go86
1 files changed, 85 insertions, 1 deletions
diff --git a/windowNewPatchsets.go b/windowNewPatchsets.go
index 59c9d15..fced45d 100644
--- a/windowNewPatchsets.go
+++ b/windowNewPatchsets.go
@@ -5,6 +5,8 @@ package main
import (
"fmt"
+ "regexp"
+ "strings"
"sync"
"go.wit.com/gui"
@@ -88,7 +90,7 @@ func makePatchsetsWin() *stdPatchsetTableWin {
savePatchsets()
})
- grid.NewButton("analyse and save patchsets", func() {
+ grid.NewButton("set patchset state", func() {
if me.psets == nil {
log.Info("No Patchsets loaded")
return
@@ -106,6 +108,24 @@ func makePatchsetsWin() *stdPatchsetTableWin {
savePatchsets()
})
+ grid.NewButton("find commit hashes", func() {
+ if me.psets == nil {
+ log.Info("No Patchsets loaded")
+ return
+ }
+ all := me.psets.All()
+ for all.Scan() {
+ pset := all.Next()
+ if pset.State == "" {
+ log.Info("What is up with?", pset.Name)
+ setNewCommitHash(pset)
+ } else {
+ log.Info("patchset already had state", pset.Name, pset.State)
+ }
+ }
+ savePatchsets()
+ })
+
// make a box at the bottom of the window for the protobuf table
dwin.box = dwin.win.Bottom.Box().SetProgName("TBOX")
@@ -192,6 +212,15 @@ func AddPatchsetsPB(tbox *gui.Node, pb *forgepb.Patchsets) *forgepb.PatchsetsTab
t.AddUuid()
+ newCommit := t.AddButtonFunc("new hash", func(p *forgepb.Patchset) string {
+ return "find"
+ })
+ newCommit.Custom = func(pset *forgepb.Patchset) {
+ log.Info("find new commits here", pset.Name)
+ // makePatchesWin(pset.Patches)
+ setNewCommitHash(pset)
+ }
+
t.ShowTable()
return t
}
@@ -240,3 +269,58 @@ func setPatchsetState(p *forgepb.Patchset) {
return
}
}
+
+func cleanSubject(line string) string {
+ // Regular expression to remove "Subject:" and "[PATCH...]" patterns
+ re := regexp.MustCompile(`(?i)^Subject:\s*(\[\s*PATCH[^\]]*\]\s*)?`)
+ cleaned := re.ReplaceAllString(line, "")
+ return strings.TrimSpace(cleaned)
+}
+
+func setNewCommitHash(p *forgepb.Patchset) {
+ for patch := range p.Patches.IterAll() {
+ // parts := strings.Fields(patch.Comment)
+
+ repo := me.forge.FindByGoPath(patch.RepoNamespace)
+ if repo == nil {
+ log.Info("couldn't find repo", patch.RepoNamespace)
+ continue
+ }
+
+ comment := cleanSubject(patch.Comment)
+
+ if patch.NewHash != "na" {
+ log.Info("patch: newhash:", patch.NewHash, "commithash:", patch.CommitHash, patch.RepoNamespace, comment)
+ continue
+ }
+ log.Info("patch: not found hash:", patch.CommitHash, patch.RepoNamespace, comment)
+ for dep := range repo.GoDeps.IterAll() {
+ log.Info("dep:", dep.Name)
+ }
+ return
+
+ /*
+ 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
+ }
+ */
+ }
+}