slim down this window to keep it functional
This commit is contained in:
parent
e548b0fb6d
commit
54b50299f3
|
@ -114,16 +114,7 @@ func (r *patchesWindow) addPatchset(line string) {
|
|||
r.setgrid.NewLabel(name)
|
||||
r.setgrid.NewLabel(subject)
|
||||
r.setgrid.NewLabel(author)
|
||||
/*
|
||||
r.setgrid.NewButton("Download", func() {
|
||||
pset, err := savePatch(name)
|
||||
if err != nil {
|
||||
log.Info(name, "failed to download", err)
|
||||
return
|
||||
}
|
||||
r.setlist[name] = pset
|
||||
})
|
||||
*/
|
||||
|
||||
r.setgrid.NewButton("View", func() {
|
||||
// has the window already been created?
|
||||
win := r.setwin[name]
|
||||
|
@ -143,44 +134,5 @@ func (r *patchesWindow) addPatchset(line string) {
|
|||
r.setwin[name] = makePatchWindow(pset)
|
||||
r.setwin[name].Show()
|
||||
})
|
||||
r.setgrid.NewButton("Dump", func() {
|
||||
pset := r.setlist[name]
|
||||
if pset == nil {
|
||||
log.Info(name, "was nil")
|
||||
return
|
||||
}
|
||||
if !dumpPatchset(pset) {
|
||||
log.Info("Dump: some patches are bad", name)
|
||||
return
|
||||
}
|
||||
})
|
||||
r.setgrid.NewButton("Extract", func() {
|
||||
pset := r.setlist[name]
|
||||
if pset == nil {
|
||||
log.Info(name, "was nil")
|
||||
return
|
||||
}
|
||||
if err := savePatchset(pset); err != nil {
|
||||
log.Info("Save: some patches are bad", name, err)
|
||||
return
|
||||
}
|
||||
})
|
||||
r.setgrid.NewButton("Apply", func() {
|
||||
pset := r.setlist[name]
|
||||
if pset == nil {
|
||||
log.Info(name, "was nil")
|
||||
return
|
||||
}
|
||||
if _, _, _, err := IsEverythingOnDevel(); err != nil {
|
||||
log.Info("You can only apply patches to the devel branch")
|
||||
return
|
||||
}
|
||||
if IsAnythingDirty() {
|
||||
log.Info("You can't apply patches when repos are dirty")
|
||||
me.forge.PrintHumanTable(me.found)
|
||||
return
|
||||
}
|
||||
applyPatchset(pset)
|
||||
})
|
||||
r.setgrid.NextRow()
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
||||
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.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(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() {
|
||||
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()
|
||||
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
|
||||
}
|
||||
|
||||
// var repo *gitpb.Repo
|
||||
|
||||
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())
|
||||
})
|
||||
r.setgrid.NewButton("Apply", func() {
|
||||
})
|
||||
r.setgrid.NextRow()
|
||||
grid.NextRow()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue