2024-02-17 14:20:37 -06:00
|
|
|
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 {
|
2024-02-19 19:41:48 -06:00
|
|
|
win *gadgets.BasicWindow
|
|
|
|
box *gui.Node
|
|
|
|
|
|
|
|
// the top box of the repolist window
|
|
|
|
topbox *gui.Node
|
|
|
|
|
2024-02-17 14:20:37 -06:00
|
|
|
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?")
|
|
|
|
}
|
|
|
|
|
2024-02-19 19:41:48 -06:00
|
|
|
r.topbox = r.repoAllButtons()
|
2024-02-17 14:20:37 -06:00
|
|
|
|
|
|
|
r.View = repolist.AutotypistView(r.box)
|
|
|
|
|
2024-02-19 19:41:48 -06:00
|
|
|
showncount := r.View.MirrorShownCount()
|
|
|
|
r.topbox.Append(showncount)
|
2024-02-20 14:44:12 -06:00
|
|
|
duration := r.View.MirrorScanDuration()
|
|
|
|
r.topbox.Append(duration)
|
|
|
|
|
2024-02-19 19:41:48 -06:00
|
|
|
r.View.RegisterHideFunction(hideFunction)
|
2024-02-17 14:20:37 -06:00
|
|
|
return r
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *repoWindow) showApps() {
|
2024-11-16 00:07:00 -06:00
|
|
|
loop := me.repos.View.ReposSortByName()
|
|
|
|
for loop.Scan() {
|
|
|
|
repo := loop.Repo()
|
2024-02-17 15:47:46 -06:00
|
|
|
switch repo.Status.RepoType() {
|
2024-02-17 14:20:37 -06:00
|
|
|
case "binary":
|
|
|
|
//log.Info("compile here. Show()")
|
|
|
|
repo.Show()
|
|
|
|
case "library":
|
|
|
|
//log.Info("library here. Hide()")
|
|
|
|
repo.Hide()
|
|
|
|
default:
|
|
|
|
log.Info("showApps() unknown. Show()")
|
|
|
|
repo.Hide()
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-19 19:41:48 -06:00
|
|
|
func (r *repoWindow) repoAllButtons() *gui.Node {
|
2024-02-17 14:20:37 -06:00
|
|
|
// 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("test all builds", func() {
|
|
|
|
r.Disable()
|
|
|
|
defer r.Enable()
|
|
|
|
r.showApps()
|
2024-11-16 00:07:00 -06:00
|
|
|
loop := me.repos.View.ReposSortByName()
|
|
|
|
for loop.Scan() {
|
|
|
|
repo := loop.Repo()
|
2024-02-17 14:20:37 -06:00
|
|
|
if repo.Hidden() {
|
|
|
|
// log.Info("skip hidden", repo.String())
|
|
|
|
} else {
|
2024-02-17 15:47:46 -06:00
|
|
|
log.Info("try to build", repo.Name())
|
|
|
|
if repo.Status.Build() {
|
|
|
|
log.Info("build worked", repo.Name())
|
2024-02-17 14:20:37 -06:00
|
|
|
} else {
|
2024-02-17 15:47:46 -06:00
|
|
|
log.Info("build failed", repo.Name())
|
|
|
|
go repo.Status.Xterm("bash")
|
2024-02-17 14:20:37 -06:00
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
log.Info("")
|
|
|
|
log.Info("every build worked !!!")
|
|
|
|
log.Info("")
|
|
|
|
})
|
2024-02-19 19:41:48 -06:00
|
|
|
return box2
|
2024-02-17 14:20:37 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
func (r *repoWindow) mergeAllDevelToMain() bool {
|
|
|
|
log.Info("merge all here")
|
2024-11-16 00:07:00 -06:00
|
|
|
loop := me.repos.View.ReposSortByName()
|
|
|
|
for loop.Scan() {
|
|
|
|
repo := loop.Repo()
|
2024-02-17 14:20:37 -06:00
|
|
|
if repo.ReadOnly() {
|
2024-02-17 15:47:46 -06:00
|
|
|
log.Info("skipping readonly", repo.Name(), repo.State())
|
2024-02-17 14:20:37 -06:00
|
|
|
continue
|
|
|
|
}
|
2024-02-17 15:47:46 -06:00
|
|
|
if repo.State() != "merge to main" {
|
|
|
|
log.Info("skipping. not merge to main", repo.Name(), repo.State())
|
2024-02-17 14:20:37 -06:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
if repo.CheckDirty() {
|
2024-02-17 15:47:46 -06:00
|
|
|
log.Info("skipping dirty", repo.Name(), repo.State())
|
2024-02-17 14:20:37 -06:00
|
|
|
continue
|
|
|
|
}
|
2024-02-17 15:47:46 -06:00
|
|
|
log.Info("found", repo.Name(), repo.State())
|
2024-02-17 14:20:37 -06:00
|
|
|
repo.NewScan()
|
2024-02-17 15:47:46 -06:00
|
|
|
if repo.Status.MergeDevelToMaster() {
|
2024-02-17 14:20:37 -06:00
|
|
|
log.Warn("THINGS SEEM OK fullAutomation() returned true.")
|
|
|
|
} else {
|
2024-02-17 15:47:46 -06:00
|
|
|
log.Warn("last repo:", repo.Name())
|
2024-02-17 14:20:37 -06:00
|
|
|
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")
|
2024-11-16 00:07:00 -06:00
|
|
|
loop := me.repos.View.ReposSortByName()
|
|
|
|
for loop.Scan() {
|
|
|
|
repo := loop.Repo()
|
2024-02-17 14:20:37 -06:00
|
|
|
if repo.ReadOnly() {
|
2024-02-17 15:47:46 -06:00
|
|
|
log.Info("skipping readonly", repo.Name(), repo.State())
|
2024-02-17 14:20:37 -06:00
|
|
|
continue
|
|
|
|
}
|
2024-02-17 15:47:46 -06:00
|
|
|
if repo.State() != "merge to devel" {
|
|
|
|
log.Info("skipping. not merge to devel", repo.Name(), repo.State())
|
2024-02-17 14:20:37 -06:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
if repo.CheckDirty() {
|
2024-02-17 15:47:46 -06:00
|
|
|
log.Info("skipping dirty", repo.Name(), repo.State())
|
2024-02-17 14:20:37 -06:00
|
|
|
continue
|
|
|
|
}
|
2024-02-17 15:47:46 -06:00
|
|
|
log.Info("found", repo.Name(), repo.State())
|
2024-02-17 14:20:37 -06:00
|
|
|
repo.NewScan()
|
2024-02-17 15:47:46 -06:00
|
|
|
if repo.Status.MergeUserToDevel() {
|
2024-02-17 14:20:37 -06:00
|
|
|
log.Warn("THINGS SEEM OK fullAutomation() returned true.")
|
|
|
|
} else {
|
2024-02-17 15:47:46 -06:00
|
|
|
log.Warn("last repo:", repo.Status.Path())
|
2024-02-17 14:20:37 -06:00
|
|
|
log.Warn("THINGS FAILED fullAutomation() returned false")
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
repo.NewScan()
|
|
|
|
}
|
|
|
|
log.Warn("EVERYTHING WORKED")
|
|
|
|
return true
|
|
|
|
}
|