192 lines
4.0 KiB
Go
192 lines
4.0 KiB
Go
package main
|
|
|
|
import (
|
|
"go.wit.com/lib/gadgets"
|
|
"go.wit.com/lib/gui/repolist"
|
|
"go.wit.com/log"
|
|
|
|
"go.wit.com/gui"
|
|
)
|
|
|
|
type repoWindow struct {
|
|
win *gadgets.BasicWindow
|
|
box *gui.Node
|
|
|
|
// the top box of the repolist window
|
|
topbox *gui.Node
|
|
|
|
View *repolist.RepoList
|
|
}
|
|
|
|
func (r *repoWindow) Hidden() bool {
|
|
return r.win.Hidden()
|
|
}
|
|
|
|
func (r *repoWindow) Show() {
|
|
r.win.Show()
|
|
}
|
|
|
|
func (r *repoWindow) Hide() {
|
|
r.win.Hide()
|
|
}
|
|
|
|
func (r *repoWindow) Disable() {
|
|
r.box.Disable()
|
|
}
|
|
|
|
func (r *repoWindow) Enable() {
|
|
r.box.Enable()
|
|
}
|
|
|
|
// you can only have one of these
|
|
func makeRepoView() *repoWindow {
|
|
if me.repos != nil {
|
|
return me.repos
|
|
}
|
|
r := new(repoWindow)
|
|
r.win = gadgets.RawBasicWindow("All git repositories in ~/go/src/")
|
|
r.win.Make()
|
|
|
|
r.box = r.win.Box().NewBox("bw vbox", false)
|
|
// me.reposwin.Draw()
|
|
r.win.Custom = func() {
|
|
log.Warn("GOT HERE: main() gadgets.NewBasicWindow() close")
|
|
log.Warn("Should I do something special here?")
|
|
}
|
|
|
|
r.topbox = r.repoMenu()
|
|
|
|
r.View = repolist.AutotypistView(r.box)
|
|
|
|
showncount := r.View.MirrorShownCount()
|
|
r.topbox.Append(showncount)
|
|
duration := r.View.MirrorScanDuration()
|
|
r.topbox.Append(duration)
|
|
return r
|
|
}
|
|
|
|
func (r *repoWindow) repoMenu() *gui.Node {
|
|
// reposbox.SetExpand(false)
|
|
group1 := r.box.NewGroup("Run on all repos:")
|
|
|
|
hbox := group1.Box()
|
|
// hbox.Horizontal()
|
|
hbox.Vertical()
|
|
|
|
box2 := hbox.Box().Vertical()
|
|
/*
|
|
box2.NewButton("merge all user to devel", func() {
|
|
r.Disable()
|
|
if !r.mergeAllUserToDevel() {
|
|
return
|
|
}
|
|
r.Enable()
|
|
})
|
|
|
|
box2.NewButton("merge all devel to main", func() {
|
|
r.Disable()
|
|
if !r.mergeAllDevelToMain() {
|
|
return
|
|
}
|
|
r.Enable()
|
|
})
|
|
*/
|
|
|
|
box2.NewButton("merge it all", func() {
|
|
r.Disable()
|
|
if !r.mergeAllUserToDevel() {
|
|
return
|
|
}
|
|
if !r.mergeAllDevelToMain() {
|
|
return
|
|
}
|
|
r.Enable()
|
|
})
|
|
|
|
box2.NewButton("show apps", func() {
|
|
loop := me.repos.View.ReposSortByName()
|
|
for loop.Scan() {
|
|
repo := loop.Repo()
|
|
rtype := repo.Status.RepoType()
|
|
switch rtype {
|
|
case "'binary'":
|
|
// log.Info(repo.Status.Path(), "compile here. Show()")
|
|
repo.Show()
|
|
case "'library'":
|
|
// log.Info(repo.Status.Path(), "library here. Hide()")
|
|
repo.Hide()
|
|
default:
|
|
log.Info(repo.Status.Path(), "unknown type", rtype)
|
|
// repo.Hide()
|
|
}
|
|
}
|
|
})
|
|
box2.NewButton("scan now", func() {
|
|
log.Info("re-scanning now")
|
|
i, s := me.repos.View.ScanRepositories()
|
|
log.Info("re-scanning done", i, "repos in", s)
|
|
})
|
|
|
|
return box2
|
|
}
|
|
|
|
func (r *repoWindow) mergeAllDevelToMain() bool {
|
|
log.Info("merge all here")
|
|
for _, repo := range r.View.AllRepos() {
|
|
if repo.ReadOnly() {
|
|
log.Info("skipping readonly", repo.Name(), repo.State())
|
|
continue
|
|
}
|
|
if repo.State() != "merge to main" {
|
|
log.Info("skipping. not merge to main", repo.Name(), repo.State())
|
|
continue
|
|
}
|
|
if repo.CheckDirty() {
|
|
log.Info("skipping dirty", repo.Name(), repo.State())
|
|
continue
|
|
}
|
|
log.Info("found", repo.Name(), repo.State())
|
|
repo.NewScan()
|
|
if repo.Status.MergeDevelToMaster() {
|
|
log.Warn("THINGS SEEM OK fullAutomation() returned true.")
|
|
} else {
|
|
log.Warn("last repo:", repo.Name())
|
|
log.Warn("THINGS FAILED fullAutomation() returned false")
|
|
return false
|
|
}
|
|
repo.NewScan()
|
|
}
|
|
log.Warn("EVERYTHING WORKED")
|
|
return true
|
|
}
|
|
|
|
func (r *repoWindow) mergeAllUserToDevel() bool {
|
|
log.Info("merge all here")
|
|
for _, repo := range r.View.AllRepos() {
|
|
if repo.ReadOnly() {
|
|
log.Info("skipping readonly", repo.Name(), repo.State())
|
|
continue
|
|
}
|
|
if repo.State() != "merge to devel" {
|
|
log.Info("skipping. not merge to devel", repo.Name(), repo.State())
|
|
continue
|
|
}
|
|
if repo.CheckDirty() {
|
|
log.Info("skipping dirty", repo.Name(), repo.State())
|
|
continue
|
|
}
|
|
log.Info("found", repo.Name(), repo.State())
|
|
repo.NewScan()
|
|
if repo.Status.MergeUserToDevel() {
|
|
log.Warn("THINGS SEEM OK fullAutomation() returned true.")
|
|
} else {
|
|
log.Warn("last repo:", repo.Status.Path())
|
|
log.Warn("THINGS FAILED fullAutomation() returned false")
|
|
return false
|
|
}
|
|
repo.NewScan()
|
|
}
|
|
log.Warn("EVERYTHING WORKED")
|
|
return true
|
|
}
|