code moved to submit-patchset
This commit is contained in:
parent
584b93cab0
commit
c57b1a2155
|
@ -3,6 +3,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"go.wit.com/gui"
|
"go.wit.com/gui"
|
||||||
|
@ -53,7 +54,7 @@ func globalResetOptions(box *gui.Node) {
|
||||||
me.deleteGoSrcPkgB.SetLabel("WE ARE NOT KIDDING")
|
me.deleteGoSrcPkgB.SetLabel("WE ARE NOT KIDDING")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var totals string = "All " + me.summary.totalGoOL.String() + " Repos?"
|
var totals string = "All " + strconv.Itoa(me.repos.View.TotalGo()) + " Repos?"
|
||||||
log.Info("totals =", totals)
|
log.Info("totals =", totals)
|
||||||
if me.deleteGoSrcPkgB.String() == "WE ARE NOT KIDDING" {
|
if me.deleteGoSrcPkgB.String() == "WE ARE NOT KIDDING" {
|
||||||
me.deleteGoSrcPkgB.SetLabel(totals)
|
me.deleteGoSrcPkgB.SetLabel(totals)
|
||||||
|
|
6
main.go
6
main.go
|
@ -33,7 +33,7 @@ func main() {
|
||||||
|
|
||||||
vbox2 := me.mainbox.NewVerticalBox("BOX2")
|
vbox2 := me.mainbox.NewVerticalBox("BOX2")
|
||||||
globalBuildOptions(vbox2)
|
globalBuildOptions(vbox2)
|
||||||
me.summary = submitPatchesBox(vbox2)
|
// me.summary = submitPatchesBox(vbox2)
|
||||||
|
|
||||||
globalResetOptions(me.mainbox)
|
globalResetOptions(me.mainbox)
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ func main() {
|
||||||
handleCmdLine()
|
handleCmdLine()
|
||||||
|
|
||||||
// processing is done. update the repo summary box
|
// processing is done. update the repo summary box
|
||||||
me.summary.Update()
|
// me.summary.Update()
|
||||||
|
|
||||||
me.Enable()
|
me.Enable()
|
||||||
|
|
||||||
|
@ -59,6 +59,6 @@ func main() {
|
||||||
me.repos.View.Watchdog(func() {
|
me.repos.View.Watchdog(func() {
|
||||||
log.Info("In main()")
|
log.Info("In main()")
|
||||||
// processing is done. update the repo summary box
|
// processing is done. update the repo summary box
|
||||||
me.summary.Update()
|
// me.summary.Update()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,6 +120,14 @@ func (r *repoWindow) repoAllButtons() *gui.Node {
|
||||||
r.Enable()
|
r.Enable()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
box2.NewButton("git pull", func() {
|
||||||
|
r.Disable()
|
||||||
|
defer r.Enable()
|
||||||
|
for _, repo := range r.View.AllRepos() {
|
||||||
|
repo.RunCmd([]string{"git", "pull"})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
box2.NewButton("test all builds", func() {
|
box2.NewButton("test all builds", func() {
|
||||||
r.Disable()
|
r.Disable()
|
||||||
defer r.Enable()
|
defer r.Enable()
|
||||||
|
|
|
@ -72,7 +72,7 @@ type autoType struct {
|
||||||
// displays a summary of all the repos
|
// displays a summary of all the repos
|
||||||
// has total dirty, total read-only
|
// has total dirty, total read-only
|
||||||
// total patches, etc
|
// total patches, etc
|
||||||
summary *patchSummary
|
// summary *patchSummary
|
||||||
|
|
||||||
// when switch to user or devel branches, autocreate them
|
// when switch to user or devel branches, autocreate them
|
||||||
autoCreateBranches *gui.Node
|
autoCreateBranches *gui.Node
|
||||||
|
|
257
submitPatches.go
257
submitPatches.go
|
@ -1,257 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"path/filepath"
|
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"go.wit.com/gui"
|
|
||||||
"go.wit.com/lib/gadgets"
|
|
||||||
"go.wit.com/lib/gui/gowit"
|
|
||||||
"go.wit.com/lib/gui/repolist"
|
|
||||||
"go.wit.com/lib/gui/shell"
|
|
||||||
"go.wit.com/log"
|
|
||||||
)
|
|
||||||
|
|
||||||
/*
|
|
||||||
type patch struct {
|
|
||||||
ref string
|
|
||||||
giturl string
|
|
||||||
comment string
|
|
||||||
rs *repostatus.RepoStatus
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
type patchSummary struct {
|
|
||||||
grid *gui.Node
|
|
||||||
updateB *gui.Node
|
|
||||||
docsB *gui.Node
|
|
||||||
gitPushB *gui.Node
|
|
||||||
gitPullB *gui.Node
|
|
||||||
checkB *gui.Node
|
|
||||||
|
|
||||||
// stats
|
|
||||||
totalOL *gadgets.OneLiner
|
|
||||||
totalGoOL *gadgets.OneLiner
|
|
||||||
dirtyOL *gadgets.OneLiner
|
|
||||||
readonlyOL *gadgets.OneLiner
|
|
||||||
totalPatchesOL *gadgets.OneLiner
|
|
||||||
totalUserRepos *gui.Node
|
|
||||||
totalDevelRepos *gui.Node
|
|
||||||
totalMasterRepos *gui.Node
|
|
||||||
totalUserPatches *gui.Node
|
|
||||||
totalDevelPatches *gui.Node
|
|
||||||
totalMasterPatches *gui.Node
|
|
||||||
|
|
||||||
// patch set generation
|
|
||||||
unknownOL *gadgets.BasicEntry
|
|
||||||
unknownSubmitB *gui.Node
|
|
||||||
reason *gadgets.BasicEntry
|
|
||||||
submitB *gui.Node
|
|
||||||
allp []*repolist.Patch
|
|
||||||
}
|
|
||||||
|
|
||||||
func submitPatchesBox(box *gui.Node) *patchSummary {
|
|
||||||
s := new(patchSummary)
|
|
||||||
group1 := box.NewGroup("Submit Patches Summary")
|
|
||||||
s.grid = group1.RawGrid()
|
|
||||||
|
|
||||||
s.grid.NewButton("Update Patch Counts", func() {
|
|
||||||
var repocount, patchcount int
|
|
||||||
for _, repo := range repolist.AllRepos() {
|
|
||||||
if repo.ReadOnly() {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
i, _ := repo.GetMasterPatches()
|
|
||||||
patchcount += i
|
|
||||||
if i > 0 {
|
|
||||||
repocount += 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
s.totalMasterPatches.SetText(strconv.Itoa(patchcount) + " patches")
|
|
||||||
s.totalMasterRepos.SetText(strconv.Itoa(repocount) + " go repos")
|
|
||||||
|
|
||||||
repocount = 0
|
|
||||||
patchcount = 0
|
|
||||||
for _, repo := range repolist.AllRepos() {
|
|
||||||
if repo.ReadOnly() {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
i, _ := repo.GetUserPatches()
|
|
||||||
patchcount += i
|
|
||||||
if i > 0 {
|
|
||||||
repocount += 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
s.totalUserPatches.SetText(strconv.Itoa(patchcount) + " patches")
|
|
||||||
s.totalUserRepos.SetText(strconv.Itoa(repocount) + " go repos")
|
|
||||||
})
|
|
||||||
|
|
||||||
/* this used to be the way and should probably be revisited
|
|
||||||
s.grid.NewButton("Make Patches", func() {
|
|
||||||
for i, p := range s.allp {
|
|
||||||
log.Info(i, p.Ref, p.RS.String())
|
|
||||||
}
|
|
||||||
})
|
|
||||||
*/
|
|
||||||
|
|
||||||
s.grid.NextRow()
|
|
||||||
|
|
||||||
s.totalOL = gadgets.NewOneLiner(s.grid, "Total")
|
|
||||||
s.grid.NextRow()
|
|
||||||
|
|
||||||
s.totalGoOL = gadgets.NewOneLiner(s.grid, "Total GO")
|
|
||||||
s.grid.NextRow()
|
|
||||||
|
|
||||||
s.dirtyOL = gadgets.NewOneLiner(s.grid, "dirty")
|
|
||||||
s.grid.NextRow()
|
|
||||||
|
|
||||||
s.readonlyOL = gadgets.NewOneLiner(s.grid, "read-only")
|
|
||||||
s.grid.NextRow()
|
|
||||||
|
|
||||||
// s.grid = group1.RawGrid()
|
|
||||||
s.grid.NewLabel("")
|
|
||||||
s.grid.NewLabel("")
|
|
||||||
s.grid.NewLabel("user to devel")
|
|
||||||
s.grid.NewLabel("devel to master")
|
|
||||||
s.grid.NewLabel("master to last tag")
|
|
||||||
s.grid.NextRow()
|
|
||||||
|
|
||||||
s.grid.NewLabel("total modified")
|
|
||||||
s.grid.NewLabel("")
|
|
||||||
s.totalUserRepos = s.grid.NewLabel("x go repos")
|
|
||||||
s.totalDevelRepos = s.grid.NewLabel("")
|
|
||||||
s.totalMasterRepos = s.grid.NewLabel("x go repos")
|
|
||||||
s.grid.NextRow()
|
|
||||||
|
|
||||||
s.totalPatchesOL = gadgets.NewOneLiner(s.grid, "total commits")
|
|
||||||
s.totalUserPatches = s.grid.NewLabel("x patches")
|
|
||||||
s.totalDevelPatches = s.grid.NewLabel("")
|
|
||||||
s.totalMasterPatches = s.grid.NewLabel("x patches")
|
|
||||||
s.grid.NextRow()
|
|
||||||
|
|
||||||
s.grid.NewLabel("")
|
|
||||||
s.grid.NewLabel("")
|
|
||||||
s.grid.NewButton("merge from user", func() {
|
|
||||||
log.Info("this should make a patchset of your patches")
|
|
||||||
})
|
|
||||||
s.grid.NewButton("merge from devel", func() {
|
|
||||||
log.Info("this probably should not exist")
|
|
||||||
})
|
|
||||||
s.grid.NextRow()
|
|
||||||
|
|
||||||
group1 = box.NewGroup("Create GUI Patch Set")
|
|
||||||
s.grid = group1.RawGrid()
|
|
||||||
s.reason = gadgets.NewBasicEntry(s.grid, "patch name:")
|
|
||||||
s.reason.Custom = func() {
|
|
||||||
if s.reason.String() != "" {
|
|
||||||
s.submitB.Enable()
|
|
||||||
} else {
|
|
||||||
s.submitB.Disable()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
s.submitB = s.grid.NewButton("Submit Patches", func() {
|
|
||||||
patchdir := filepath.Join(me.userHomePwd.String(), "autotypist.patchset")
|
|
||||||
if shell.Exists(patchdir) {
|
|
||||||
log.Info("patchset dir already exists", patchdir)
|
|
||||||
return
|
|
||||||
} else {
|
|
||||||
shell.Mkdir(patchdir)
|
|
||||||
}
|
|
||||||
if !shell.Exists(patchdir) {
|
|
||||||
log.Info("something went wrong making", patchdir)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
me.repos.View.MakePatchset(patchdir)
|
|
||||||
})
|
|
||||||
// disable these until there are not dirty repos
|
|
||||||
s.reason.Disable()
|
|
||||||
s.submitB.Disable()
|
|
||||||
s.grid.NextRow()
|
|
||||||
|
|
||||||
// map a path to gitea
|
|
||||||
s.unknownOL = gadgets.NewBasicEntry(s.grid, "Unknown Repo:")
|
|
||||||
s.unknownSubmitB = s.grid.NewButton("map new repo path", func() {
|
|
||||||
log.Info("Submit repo:", s.unknownOL.String())
|
|
||||||
repo := me.repos.View.FindRepo(s.unknownOL.String())
|
|
||||||
if repo == nil {
|
|
||||||
log.Info("could not find repo:", s.unknownOL.String(), "in ~/go/src")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
localurl := repo.Status.GitURL()
|
|
||||||
log.Info("found repo:", repo.GoPath(), "with giturl", localurl)
|
|
||||||
if localurl == "" {
|
|
||||||
log.Info("local repo check failed. repo")
|
|
||||||
} else {
|
|
||||||
log.Info("local repo has", localurl)
|
|
||||||
// check if go.wit.com works, if not, add it
|
|
||||||
// attempts to register the unknown repo
|
|
||||||
if gowit.Register(repo.GoPath(), localurl) {
|
|
||||||
// todo: check if this works
|
|
||||||
// s.unknownOL.Hide()
|
|
||||||
// s.unknownSubmitB.Hide()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
s.unknownOL.Disable()
|
|
||||||
s.unknownSubmitB.Disable()
|
|
||||||
s.grid.NextRow()
|
|
||||||
|
|
||||||
return s
|
|
||||||
}
|
|
||||||
|
|
||||||
// does not run any commands
|
|
||||||
func (s *patchSummary) Update() {
|
|
||||||
var total, totalgo, dirty, readonly int
|
|
||||||
var userT, develT, masterT int
|
|
||||||
// var userP, develP, masterP int
|
|
||||||
for _, repo := range repolist.AllRepos() {
|
|
||||||
total += 1
|
|
||||||
if repo.Status.IsDirty() {
|
|
||||||
dirty += 1
|
|
||||||
}
|
|
||||||
if repo.Status.IsGoLang() {
|
|
||||||
totalgo += 1
|
|
||||||
}
|
|
||||||
if repo.Status.ReadOnly() {
|
|
||||||
readonly += 1
|
|
||||||
// don't count these in any further stats
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
// compute which GUI repos are out of sync with master
|
|
||||||
userV := repo.Status.GetUserVersion()
|
|
||||||
develV := repo.Status.GetDevelVersion()
|
|
||||||
masterV := repo.Status.GetMasterVersion()
|
|
||||||
lastV := repo.Status.GetLastTagVersion()
|
|
||||||
if userV != develV {
|
|
||||||
userT += 1
|
|
||||||
}
|
|
||||||
if develV != masterV {
|
|
||||||
log.Info("develV != masterV", develV, masterV, repo.GoPath())
|
|
||||||
develT += 1
|
|
||||||
}
|
|
||||||
if masterV != lastV {
|
|
||||||
masterT += 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
s.totalOL.SetText(strconv.Itoa(total) + " repos")
|
|
||||||
s.totalGoOL.SetText(strconv.Itoa(totalgo) + " repos")
|
|
||||||
s.dirtyOL.SetText(strconv.Itoa(dirty) + " repos")
|
|
||||||
s.readonlyOL.SetText(strconv.Itoa(readonly) + " repos")
|
|
||||||
|
|
||||||
s.totalUserRepos.SetText(strconv.Itoa(userT) + " repos")
|
|
||||||
s.totalDevelRepos.SetText(strconv.Itoa(develT) + " repos")
|
|
||||||
s.totalMasterRepos.SetText(strconv.Itoa(masterT) + " repos")
|
|
||||||
|
|
||||||
if dirty == 0 {
|
|
||||||
s.reason.Enable()
|
|
||||||
s.submitB.Enable()
|
|
||||||
s.unknownOL.Enable()
|
|
||||||
s.unknownSubmitB.Enable()
|
|
||||||
} else {
|
|
||||||
s.reason.Disable()
|
|
||||||
s.submitB.Enable()
|
|
||||||
s.unknownOL.Enable()
|
|
||||||
s.unknownSubmitB.Enable()
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue