summaryrefslogtreecommitdiff
path: root/windowViewPatch.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-01-29 11:23:34 -0600
committerJeff Carr <[email protected]>2025-01-29 12:18:16 -0600
commit54b50299f394b45da0f46bf47715cac79ca837f0 (patch)
treecdbeb0950b86005f0cc9ef0f026addd6811f1b37 /windowViewPatch.go
parente548b0fb6d0d14cdfb693850d592419f247dc2b1 (diff)
slim down this window to keep it functional
Diffstat (limited to 'windowViewPatch.go')
-rw-r--r--windowViewPatch.go75
1 files changed, 45 insertions, 30 deletions
diff --git a/windowViewPatch.go b/windowViewPatch.go
index 4ea414d..d4b9689 100644
--- a/windowViewPatch.go
+++ b/windowViewPatch.go
@@ -1,11 +1,11 @@
package main
import (
- "strings"
"sync"
"go.wit.com/lib/gadgets"
"go.wit.com/lib/protobuf/forgepb"
+ "go.wit.com/lib/protobuf/gitpb"
"go.wit.com/log"
"go.wit.com/gui"
@@ -85,13 +85,13 @@ func makePatchWindow(pset *forgepb.Patchset) *patchWindow {
grid.NewLabel(pset.EndBranchHash)
grid.NextRow()
- grid.NewButton("Extract", func() {
+ grid.NewButton("Extract files to disk", func() {
if err := savePatchset(pset); err != nil {
log.Info("Save err:", err)
return
}
})
- grid.NewButton("Apply", func() {
+ grid.NewButton("Apply with git am", func() {
if _, _, _, err := IsEverythingOnDevel(); err != nil {
log.Info("You can only apply patches to the devel branch")
return
@@ -108,39 +108,54 @@ func makePatchWindow(pset *forgepb.Patchset) *patchWindow {
g := pw.stack.NewGroup("PatchSet List")
- // add the patch grid
+ // make a grid and a header
filegrid := g.NewGrid("", 0, 0)
+ filegrid.NewLabel("repo")
+ filegrid.NewLabel("patch name")
+ filegrid.NewLabel("Applied in current branch?")
+ filegrid.NewLabel("start hash")
+ filegrid.NextRow()
+ // add the patches to the grid
+ pw.addPatchset(filegrid, pset)
+ return pw
+}
+
+func (r *patchWindow) addPatchset(grid *gui.Node, pset *forgepb.Patchset) {
+ repomap := make(map[*gitpb.Repo][]*forgepb.Patch)
+ repohash := make(map[*gitpb.Repo]string)
+
+ // sort patches by repo namespace
all := pset.Patches.SortByFilename()
for all.Scan() {
p := all.Next()
- // if IsValidPatch(p) {
- filegrid.NewLabel(p.RepoNamespace)
- filegrid.NewLabel(p.Comment)
- filegrid.NewLabel(p.Filename)
- filegrid.NewLabel(p.RepoPath)
- filegrid.NewLabel(p.BranchName)
- filegrid.NewLabel(p.BranchHash)
- filegrid.NewLabel(p.CommitHash)
- filegrid.NewLabel(p.StartHash)
- filegrid.NextRow()
+ s := p.RepoNamespace
+ repo := me.forge.FindByGoPath(s)
+ if repo == nil {
+ log.Info("COULD NOT FIND", s)
+ continue
+ }
+ repomap[repo] = append(repomap[repo], p)
+ repohash[repo] = p.StartHash
}
- return pw
-}
+ // var repo *gitpb.Repo
-func (r *patchWindow) addPatchset(line string) {
- parts := strings.Split(line, "Author:")
- author := parts[1]
- parts = strings.Fields(parts[0])
- name := parts[0]
- subject := strings.Join(parts[1:], " ")
- r.setgrid.NewLabel(name)
- r.setgrid.NewLabel(subject)
- r.setgrid.NewLabel(author)
- r.setgrid.NewButton("Download", func() {
- })
- r.setgrid.NewButton("Apply", func() {
- })
- r.setgrid.NextRow()
+ for repo, patches := range repomap {
+ log.Info(repo.GetGoPath())
+ grid.NewLabel(repo.GetGoPath())
+
+ for i, p := range patches {
+ log.Info(i, p.Filename)
+ grid.NewLabel(p.Comment)
+ grid.NewLabel("in current branch?")
+ break
+ }
+ hash := repohash[repo]
+ grid.NewLabel(hash)
+ grid.NewButton("View", func() {
+ log.Info("todo: show patches for repo", repo.GetGoPath())
+ })
+ grid.NextRow()
+ }
}