2025-02-01 11:57:52 -06:00
|
|
|
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
|
|
|
|
// Use of this source code is governed by the GPL 3.0
|
|
|
|
|
2024-12-05 12:29:47 -06:00
|
|
|
package main
|
|
|
|
|
|
|
|
// An app to submit patches for the 30 GO GUI repos
|
|
|
|
|
|
|
|
import (
|
2025-02-21 08:20:44 -06:00
|
|
|
"fmt"
|
2025-01-19 02:56:48 -06:00
|
|
|
"os"
|
2025-01-30 18:46:35 -06:00
|
|
|
"time"
|
2025-01-19 02:56:48 -06:00
|
|
|
|
2024-12-05 12:29:47 -06:00
|
|
|
"go.wit.com/gui"
|
2025-02-13 20:10:45 -06:00
|
|
|
"go.wit.com/lib/debugger"
|
2024-12-05 12:29:47 -06:00
|
|
|
"go.wit.com/lib/gadgets"
|
2025-01-30 18:46:35 -06:00
|
|
|
"go.wit.com/lib/gui/shell"
|
2025-03-02 04:13:10 -06:00
|
|
|
"go.wit.com/lib/protobuf/forgepb"
|
2025-02-13 22:52:10 -06:00
|
|
|
"go.wit.com/lib/protobuf/gitpb"
|
2024-12-05 12:29:47 -06:00
|
|
|
"go.wit.com/log"
|
|
|
|
)
|
|
|
|
|
2025-01-08 04:07:33 -06:00
|
|
|
func debug() {
|
2025-02-21 18:31:26 -06:00
|
|
|
time.Sleep(2 * time.Second)
|
2025-02-10 23:42:21 -06:00
|
|
|
for {
|
2025-02-21 08:20:44 -06:00
|
|
|
now := time.Now()
|
2025-03-04 00:27:15 -06:00
|
|
|
|
2025-03-02 08:13:43 -06:00
|
|
|
if me.repoAllB != nil {
|
|
|
|
tmp := fmt.Sprintf("All (%d)", me.forge.Repos.Len())
|
|
|
|
me.repoAllB.SetLabel(tmp)
|
|
|
|
}
|
2025-02-21 08:20:44 -06:00
|
|
|
|
2025-03-02 08:13:43 -06:00
|
|
|
if me.repoDevelMergeB != nil {
|
|
|
|
found := findMergeToDevel()
|
|
|
|
tmp := fmt.Sprintf("needs merge to devel (%d)", found.Len())
|
|
|
|
me.repoDevelMergeB.SetLabel(tmp)
|
|
|
|
}
|
2025-02-21 08:20:44 -06:00
|
|
|
|
2025-03-02 08:13:43 -06:00
|
|
|
if me.repoWritableB != nil {
|
|
|
|
found := gitpb.NewRepos()
|
|
|
|
all := me.forge.Repos.SortByFullPath()
|
|
|
|
for all.Scan() {
|
|
|
|
repo := all.Next()
|
|
|
|
if me.forge.Config.IsReadOnly(repo.GetGoPath()) {
|
|
|
|
continue
|
|
|
|
}
|
2025-02-21 08:20:44 -06:00
|
|
|
|
2025-03-02 08:13:43 -06:00
|
|
|
found.AppendByGoPath(repo)
|
2025-02-21 08:20:44 -06:00
|
|
|
|
2025-03-02 08:13:43 -06:00
|
|
|
}
|
|
|
|
tmp := fmt.Sprintf("writable (%d)", found.Len())
|
|
|
|
me.repoWritableB.SetLabel(tmp)
|
2025-02-21 08:20:44 -06:00
|
|
|
}
|
|
|
|
|
2025-03-04 00:27:15 -06:00
|
|
|
doCheckDirtyAndConfigSave()
|
|
|
|
found := findDirty()
|
|
|
|
dirty := found.Len()
|
|
|
|
|
2025-03-02 08:13:43 -06:00
|
|
|
if me.repoDirtyB != nil {
|
2025-03-04 00:27:15 -06:00
|
|
|
tmp := fmt.Sprintf("dirty (%d)", dirty)
|
2025-03-02 08:13:43 -06:00
|
|
|
me.repoDirtyB.SetLabel(tmp)
|
|
|
|
}
|
2025-02-21 08:20:44 -06:00
|
|
|
|
2025-03-04 00:27:15 -06:00
|
|
|
if me.reposWinB != nil {
|
|
|
|
tmp := fmt.Sprintf("Repos (%d)", me.forge.Repos.Len())
|
|
|
|
if dirty > 0 {
|
|
|
|
tmp = fmt.Sprintf("Repos (%d) (%d dirty)", me.forge.Repos.Len(), dirty)
|
|
|
|
}
|
|
|
|
me.reposWinB.SetLabel(tmp)
|
|
|
|
}
|
|
|
|
|
2025-02-21 08:20:44 -06:00
|
|
|
log.Printf("finished a forge scan here in (%s)\n", shell.FormatDuration(time.Since(now)))
|
2025-02-10 23:42:21 -06:00
|
|
|
time.Sleep(90 * time.Second)
|
|
|
|
}
|
2025-01-08 04:07:33 -06:00
|
|
|
}
|
|
|
|
|
2024-12-05 12:29:47 -06:00
|
|
|
func doGui() {
|
2025-01-20 05:08:52 -06:00
|
|
|
if me.forge.Config.GetDefaultGui() == "" {
|
|
|
|
me.forge.Config.DefaultGui = "gocui"
|
|
|
|
me.forge.ConfigSave()
|
|
|
|
}
|
2024-12-05 12:29:47 -06:00
|
|
|
me.myGui = gui.New()
|
2025-01-20 05:08:52 -06:00
|
|
|
me.myGui.InitEmbed(resources)
|
|
|
|
me.myGui.SetAppDefaultPlugin(me.forge.Config.DefaultGui) // sets the default GUI plugin to use
|
2024-12-05 12:29:47 -06:00
|
|
|
me.myGui.Default()
|
|
|
|
|
2025-03-03 23:49:24 -06:00
|
|
|
mainWindow := gadgets.NewGenericWindow("Forge: (this kinda works sometimes)", "Current Settings")
|
2025-01-30 07:30:04 -06:00
|
|
|
mainWindow.Custom = func() {
|
2025-01-19 02:56:48 -06:00
|
|
|
log.Warn("MAIN WINDOW CLOSE")
|
2025-01-30 18:46:35 -06:00
|
|
|
now := time.Now()
|
2025-01-19 02:56:48 -06:00
|
|
|
count := me.forge.RillReload()
|
|
|
|
log.Info("Repo Reload count =", count)
|
|
|
|
if count != 0 {
|
|
|
|
me.forge.ConfigSave()
|
|
|
|
}
|
2025-01-30 18:46:35 -06:00
|
|
|
log.Printf("rill repos.Reload() took (%s)\n", shell.FormatDuration(time.Since(now)))
|
2025-01-19 02:56:48 -06:00
|
|
|
os.Exit(0)
|
|
|
|
}
|
|
|
|
|
2025-01-30 07:30:04 -06:00
|
|
|
drawWindow(mainWindow)
|
2024-12-05 12:29:47 -06:00
|
|
|
|
2025-01-30 07:12:47 -06:00
|
|
|
// sits here forever
|
|
|
|
debug()
|
2024-12-05 12:29:47 -06:00
|
|
|
|
2025-01-20 02:50:07 -06:00
|
|
|
}
|
|
|
|
|
2025-03-03 23:49:24 -06:00
|
|
|
func drawWindow(win *gadgets.GenericWindow) {
|
|
|
|
grid := win.Group.RawGrid()
|
2025-01-31 08:49:19 -06:00
|
|
|
me.goSrcPwd = gadgets.NewOneLiner(grid, "repo src home")
|
2025-02-22 04:46:45 -06:00
|
|
|
grid.NewLabel("")
|
2025-03-04 04:12:14 -06:00
|
|
|
var howtoWin *gadgets.GenericWindow
|
2025-02-22 06:52:40 -06:00
|
|
|
me.demoB = grid.NewButton("Howto", func() {
|
|
|
|
if howtoWin != nil {
|
|
|
|
howtoWin.Toggle()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
howtoWin = makeHowtoWin()
|
2025-02-22 04:46:45 -06:00
|
|
|
})
|
2025-01-20 02:50:07 -06:00
|
|
|
grid.NextRow()
|
|
|
|
|
2025-02-22 06:52:40 -06:00
|
|
|
me.goSrcPwd.SetText(me.forge.GetGoSrc())
|
2025-01-20 02:50:07 -06:00
|
|
|
|
|
|
|
// use ENV GIT_AUTHOR
|
|
|
|
me.gitAuthor = gadgets.NewOneLiner(grid, "Git Author")
|
|
|
|
grid.NextRow()
|
|
|
|
|
|
|
|
if os.Getenv("GIT_AUTHOR_NAME") == "" {
|
|
|
|
me.gitAuthor.SetText("ENV GIT_AUTHOR_NAME is unset")
|
|
|
|
} else {
|
|
|
|
author := os.Getenv("GIT_AUTHOR_NAME")
|
|
|
|
author += " <" + os.Getenv("GIT_AUTHOR_EMAIL") + ">"
|
|
|
|
me.gitAuthor.SetText(author)
|
|
|
|
}
|
|
|
|
|
2025-03-03 23:49:24 -06:00
|
|
|
group1 := win.Stack.NewGroup("Forge Mode")
|
|
|
|
grid = group1.RawGrid()
|
|
|
|
me.forgeMode = grid.NewLabel("")
|
2025-03-02 03:03:29 -06:00
|
|
|
me.forgeMode.SetText(me.forge.GetMode())
|
|
|
|
|
2025-03-02 17:44:02 -06:00
|
|
|
me.newBranch = grid.NewDropdown()
|
|
|
|
me.newBranch.AddText("master")
|
|
|
|
me.newBranch.AddText("devel")
|
|
|
|
me.newBranch.AddText(me.forge.Config.GetUsername())
|
|
|
|
me.newBranch.Custom = func() {
|
|
|
|
me.setBranchB.Disable()
|
|
|
|
// toggle global values shared by the command line and the gui for doCheckout()
|
|
|
|
switch me.newBranch.String() {
|
|
|
|
case "master":
|
|
|
|
if me.forge.Config.Mode != forgepb.ForgeMode_MASTER {
|
|
|
|
me.setBranchB.Enable()
|
|
|
|
}
|
|
|
|
case "devel":
|
|
|
|
if me.forge.Config.Mode != forgepb.ForgeMode_DEVEL {
|
|
|
|
me.setBranchB.Enable()
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
if me.forge.Config.Mode != forgepb.ForgeMode_USER {
|
|
|
|
me.setBranchB.Enable()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-01-20 02:50:07 -06:00
|
|
|
// select the branch you want to test, build and develop against
|
|
|
|
// this lets you select your user branch, but, when you are happy
|
|
|
|
// you can merge everything into the devel branch and make sure it actually
|
|
|
|
// works. Then, when that is good, merge and version everything in master
|
2025-03-02 17:44:02 -06:00
|
|
|
me.setBranchB = grid.NewButton("Switch mode", func() {
|
2025-02-02 16:26:18 -06:00
|
|
|
win.Disable()
|
|
|
|
defer win.Enable()
|
2025-02-10 23:42:21 -06:00
|
|
|
|
2025-02-09 02:22:22 -06:00
|
|
|
switch me.newBranch.String() {
|
|
|
|
case "master":
|
2025-03-02 04:13:10 -06:00
|
|
|
forgeSwitchMode(forgepb.ForgeMode_MASTER)
|
2025-02-09 02:22:22 -06:00
|
|
|
case "devel":
|
2025-03-02 04:13:10 -06:00
|
|
|
forgeSwitchMode(forgepb.ForgeMode_DEVEL)
|
2025-02-09 02:22:22 -06:00
|
|
|
default:
|
2025-03-02 04:13:10 -06:00
|
|
|
forgeSwitchMode(forgepb.ForgeMode_USER)
|
2025-02-09 02:22:22 -06:00
|
|
|
}
|
2025-03-02 17:44:02 -06:00
|
|
|
|
|
|
|
me.setBranchB.Disable()
|
|
|
|
})
|
|
|
|
me.setBranchB.Disable()
|
2025-01-20 02:50:07 -06:00
|
|
|
|
2025-03-02 04:13:10 -06:00
|
|
|
grid.NextRow()
|
|
|
|
|
2025-03-03 23:49:24 -06:00
|
|
|
groupM := win.Stack.NewGroup("Mode Windows")
|
2025-03-02 04:13:10 -06:00
|
|
|
gridM := groupM.RawGrid()
|
2025-03-04 04:06:16 -06:00
|
|
|
|
|
|
|
var releaseWin *gadgets.GenericWindow
|
2025-03-02 04:13:10 -06:00
|
|
|
me.modeReleaseW = gridM.NewButton("Release Window", func() {
|
|
|
|
log.Info("todo: move releaser here")
|
|
|
|
log.Info("for now, run guireleaser")
|
2025-03-04 04:06:16 -06:00
|
|
|
if releaseWin != nil {
|
|
|
|
releaseWin.Toggle()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
releaseWin = makeModeMasterWin()
|
2025-03-02 04:13:10 -06:00
|
|
|
})
|
2025-03-02 07:49:30 -06:00
|
|
|
me.modeReleaseW.Disable()
|
|
|
|
|
|
|
|
// the Devel / Patch mode window
|
|
|
|
var patchWin *patchesWindow
|
2025-03-02 04:13:10 -06:00
|
|
|
me.modePatchW = gridM.NewButton("Patch Window", func() {
|
2025-03-02 07:49:30 -06:00
|
|
|
if patchWin != nil {
|
|
|
|
patchWin.Toggle()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
patchWin = new(patchesWindow)
|
|
|
|
patchWin.initWindow()
|
|
|
|
patchWin.Show()
|
2025-03-02 04:13:10 -06:00
|
|
|
})
|
2025-03-02 07:49:30 -06:00
|
|
|
me.modePatchW.Disable()
|
|
|
|
|
|
|
|
// the user mode "hack Window"
|
2025-03-04 04:12:14 -06:00
|
|
|
var hackWin *gadgets.GenericWindow
|
2025-03-02 04:13:10 -06:00
|
|
|
me.modeUserW = gridM.NewButton("Hack Window", func() {
|
2025-03-02 07:49:30 -06:00
|
|
|
if hackWin != nil {
|
|
|
|
hackWin.Toggle()
|
|
|
|
return
|
|
|
|
}
|
2025-03-04 04:12:14 -06:00
|
|
|
hackWin := gadgets.NewGenericWindow("Hack / User Mode Window", "Things that might be wrong")
|
2025-03-02 07:49:30 -06:00
|
|
|
grid := hackWin.Group.RawGrid()
|
|
|
|
grid.NewButton("git pull", func() {
|
|
|
|
log.Info("todo: run git pull on each repo")
|
|
|
|
})
|
2025-03-02 08:13:43 -06:00
|
|
|
|
|
|
|
me.repoDevelMergeB = grid.NewButton("merge", func() {
|
|
|
|
found := findMergeToDevel()
|
|
|
|
_, box := makeStandardReposWindow("repos to merge from user to devel", found)
|
|
|
|
hbox := box.Box().Horizontal()
|
|
|
|
hbox.NewButton("merge all", func() {
|
|
|
|
win.Disable()
|
|
|
|
defer win.Enable()
|
|
|
|
all := found.SortByFullPath()
|
|
|
|
for all.Scan() {
|
|
|
|
repo := all.Next()
|
|
|
|
if repo.CheckDirty() {
|
|
|
|
log.Info("repo is dirty", repo.GetGoPath())
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
log.Info("Starting merge on", repo.GetGoPath())
|
|
|
|
if repo.CheckoutDevel() {
|
|
|
|
log.Info("checkout devel failed", repo.GetGoPath())
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if _, err := repo.MergeToDevel(); err != nil {
|
|
|
|
log.Info("merge from user failed", repo.GetGoPath(), err)
|
|
|
|
// log.Info(strings.Join(r.Stdout, "\n"))
|
|
|
|
// log.Info(strings.Join(r.Stderr, "\n"))
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if repo.CheckoutMaster() {
|
|
|
|
log.Info("checkout master failed", repo.GetGoPath())
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if _, err := repo.MergeToMaster(); err != nil {
|
|
|
|
log.Info("merge from devel failed", repo.GetGoPath(), err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
var problemsWin *repoProblemsWindow
|
|
|
|
grid.NewButton("Repo Problems", func() {
|
|
|
|
if problemsWin != nil {
|
|
|
|
problemsWin.Toggle()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
problemsWin = makeRepoProblemsWindow()
|
|
|
|
})
|
|
|
|
grid.NextRow()
|
|
|
|
|
|
|
|
// grid := hackWin.Group.RawGrid()
|
|
|
|
group2 := hackWin.Stack.NewGroup("Merge")
|
|
|
|
grid = group2.RawGrid()
|
|
|
|
|
|
|
|
grid.NewButton("merge to devel", func() {
|
|
|
|
win.Disable()
|
|
|
|
defer win.Enable()
|
|
|
|
|
|
|
|
mergeUserToDevel(true)
|
|
|
|
})
|
|
|
|
|
|
|
|
grid.NewButton("merge to master", func() {
|
|
|
|
win.Disable()
|
|
|
|
defer win.Enable()
|
|
|
|
|
|
|
|
mergeDevelToMaster(true)
|
|
|
|
})
|
|
|
|
|
|
|
|
grid.NewButton("merge all", func() {
|
|
|
|
win.Disable()
|
|
|
|
defer win.Enable()
|
|
|
|
|
|
|
|
me.argvCheckoutUser = false
|
|
|
|
me.argvCheckoutDevel = true
|
|
|
|
me.argvCheckoutMaster = false
|
|
|
|
if err := doCheckoutShared(); err != nil {
|
|
|
|
log.Info("checkout error:", err)
|
|
|
|
} else {
|
|
|
|
log.Info("checkout was ok")
|
|
|
|
}
|
|
|
|
|
|
|
|
mergeUserToDevel(true)
|
|
|
|
|
|
|
|
me.argvCheckoutUser = false
|
|
|
|
me.argvCheckoutDevel = false
|
|
|
|
me.argvCheckoutMaster = true
|
|
|
|
if err := doCheckoutShared(); err != nil {
|
|
|
|
log.Info("checkout error:", err)
|
|
|
|
} else {
|
|
|
|
log.Info("checkout was ok")
|
|
|
|
}
|
|
|
|
|
|
|
|
mergeDevelToMaster(true)
|
|
|
|
})
|
|
|
|
|
|
|
|
group3 := hackWin.Stack.NewGroup("work in progress")
|
|
|
|
grid = group3.RawGrid()
|
|
|
|
|
|
|
|
grid.NewButton("forge ConfigSave()", func() {
|
|
|
|
me.forge.ConfigSave()
|
|
|
|
})
|
|
|
|
|
|
|
|
grid.NewButton("debugger()", func() {
|
|
|
|
debugger.DebugWindow()
|
|
|
|
})
|
2025-03-02 04:13:10 -06:00
|
|
|
})
|
2025-01-20 02:50:07 -06:00
|
|
|
|
2025-03-04 00:27:15 -06:00
|
|
|
var reposWin *gadgets.GenericWindow
|
|
|
|
me.reposWinB = gridM.NewButton("Repos", func() {
|
|
|
|
if reposWin != nil {
|
|
|
|
reposWin.Toggle()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
reposWin = makeReposWin()
|
|
|
|
})
|
|
|
|
|
|
|
|
// set the initial button state based on the last
|
|
|
|
// forge mode the user saved in the config file
|
|
|
|
switch me.forge.Config.Mode {
|
|
|
|
case forgepb.ForgeMode_MASTER:
|
|
|
|
me.newBranch.SetText("master")
|
|
|
|
case forgepb.ForgeMode_DEVEL:
|
|
|
|
me.newBranch.SetText("devel")
|
|
|
|
case forgepb.ForgeMode_USER:
|
|
|
|
me.newBranch.SetText(me.forge.Config.GetUsername())
|
|
|
|
default:
|
|
|
|
me.newBranch.SetText(me.forge.Config.GetUsername())
|
|
|
|
}
|
|
|
|
|
|
|
|
forgeSwitchMode(me.forge.Config.Mode)
|
|
|
|
}
|
|
|
|
|
|
|
|
func makeReposWin() *gadgets.GenericWindow {
|
|
|
|
win := gadgets.NewGenericWindow("git repos", "All about git repos")
|
|
|
|
grid := win.Group.RawGrid()
|
2025-02-21 05:41:30 -06:00
|
|
|
|
2025-02-21 08:20:44 -06:00
|
|
|
me.repoDirtyB = grid.NewButton("dirty", func() {
|
2025-02-21 18:31:26 -06:00
|
|
|
doCheckDirtyAndConfigSave()
|
|
|
|
found := findDirty()
|
2025-03-03 11:59:21 -06:00
|
|
|
tb, box := makeStandardReposWindow("dirty repos", found)
|
2025-02-22 03:40:37 -06:00
|
|
|
hbox := box.Box().Horizontal()
|
|
|
|
hbox.NewButton("commit all", func() {
|
2025-02-21 18:31:26 -06:00
|
|
|
all := found.SortByFullPath()
|
|
|
|
for all.Scan() {
|
|
|
|
repo := all.Next()
|
|
|
|
log.Info("do commit here on", repo.GetGoPath())
|
|
|
|
}
|
|
|
|
log.Info("TODO: fix this")
|
|
|
|
log.Info("run 'forge commit --all'")
|
|
|
|
})
|
2025-03-03 11:59:21 -06:00
|
|
|
hbox.NewButton("update table", func() {
|
|
|
|
me.forge.PrintHumanTable(found)
|
|
|
|
found2 := findDirty()
|
|
|
|
me.forge.PrintHumanTable(found2)
|
|
|
|
tb.Update()
|
|
|
|
tb.UpdateTable(found2)
|
|
|
|
})
|
|
|
|
hbox.NewButton("delete table", func() {
|
|
|
|
tb.Delete()
|
|
|
|
})
|
2025-02-21 05:41:30 -06:00
|
|
|
})
|
|
|
|
|
2025-03-04 04:12:14 -06:00
|
|
|
var writeWin *gadgets.GenericWindow
|
2025-02-21 08:20:44 -06:00
|
|
|
me.repoWritableB = grid.NewButton("writable", func() {
|
2025-02-24 11:00:08 -06:00
|
|
|
// if the window exists, just toggle it open or closed
|
|
|
|
if writeWin != nil {
|
|
|
|
writeWin.Toggle()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// make the window for the first time
|
|
|
|
found := new(gitpb.Repos)
|
2025-02-21 08:20:44 -06:00
|
|
|
all := me.forge.Repos.SortByFullPath()
|
|
|
|
for all.Scan() {
|
|
|
|
repo := all.Next()
|
|
|
|
if me.forge.Config.IsReadOnly(repo.GetGoPath()) {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2025-02-24 11:00:08 -06:00
|
|
|
found.AppendByGoPath(repo)
|
2025-02-21 08:20:44 -06:00
|
|
|
|
|
|
|
}
|
2025-02-24 11:00:08 -06:00
|
|
|
writeWin, _ = makeWritableWindow(found)
|
|
|
|
writeWin.Win.Custom = func() {
|
|
|
|
log.Info("closing window. could do somethine here")
|
|
|
|
}
|
2025-02-21 08:20:44 -06:00
|
|
|
})
|
|
|
|
|
2025-02-21 16:55:17 -06:00
|
|
|
me.repoAllB = grid.NewButton("All", func() {
|
|
|
|
me.found = new(gitpb.Repos)
|
|
|
|
all := me.forge.Repos.SortByFullPath()
|
|
|
|
for all.Scan() {
|
|
|
|
repo := all.Next()
|
|
|
|
me.found.AppendByGoPath(repo)
|
|
|
|
|
|
|
|
}
|
|
|
|
makeStandardReposWindow("All repos", me.found)
|
|
|
|
})
|
|
|
|
|
2025-03-02 12:04:45 -06:00
|
|
|
grid.NewButton("Configure", func() {
|
|
|
|
log.Info("add a forge config window here")
|
|
|
|
})
|
2025-02-21 05:41:30 -06:00
|
|
|
|
2025-03-04 00:27:15 -06:00
|
|
|
return win
|
|
|
|
}
|
2025-03-02 04:13:10 -06:00
|
|
|
|
2025-03-04 00:27:15 -06:00
|
|
|
// verify the GUI button disable/enable settings
|
|
|
|
func forgeVerifyGuiState() {
|
2025-03-02 04:13:10 -06:00
|
|
|
me.forgeMode.SetText(me.forge.GetMode())
|
|
|
|
|
|
|
|
me.argvCheckoutUser = false
|
|
|
|
me.argvCheckoutDevel = false
|
|
|
|
me.argvCheckoutMaster = false
|
|
|
|
|
|
|
|
me.modeReleaseW.Disable()
|
|
|
|
me.modePatchW.Disable()
|
|
|
|
me.modeUserW.Disable()
|
|
|
|
|
2025-03-04 00:27:15 -06:00
|
|
|
switch me.forge.Config.Mode {
|
2025-03-02 04:13:10 -06:00
|
|
|
case forgepb.ForgeMode_MASTER:
|
|
|
|
me.argvCheckoutMaster = true
|
|
|
|
me.newBranch.SetText("master")
|
|
|
|
me.modeReleaseW.Enable()
|
|
|
|
case forgepb.ForgeMode_DEVEL:
|
|
|
|
me.argvCheckoutDevel = true
|
|
|
|
me.newBranch.SetText("devel")
|
|
|
|
me.modePatchW.Enable()
|
|
|
|
case forgepb.ForgeMode_USER:
|
|
|
|
me.newBranch.SetText(me.forge.Config.GetUsername())
|
|
|
|
me.argvCheckoutUser = true
|
|
|
|
me.modeUserW.Enable()
|
|
|
|
default:
|
|
|
|
me.newBranch.SetText(me.forge.Config.GetUsername())
|
|
|
|
me.argvCheckoutUser = true
|
|
|
|
me.modeUserW.Enable()
|
|
|
|
}
|
2025-03-04 00:27:15 -06:00
|
|
|
}
|
2025-03-02 04:13:10 -06:00
|
|
|
|
2025-03-04 00:27:15 -06:00
|
|
|
// sets the text in the labels in the window
|
|
|
|
// and hides and shows the buttons
|
|
|
|
func forgeSwitchMode(newMode forgepb.ForgeMode) {
|
|
|
|
if newMode == me.forge.Config.Mode {
|
|
|
|
log.Info("you are already on", newMode.String())
|
|
|
|
forgeVerifyGuiState() // doing this here initializes the button state
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
me.forge.Config.Mode = newMode
|
|
|
|
forgeVerifyGuiState() // update the button states
|
2025-03-02 07:49:30 -06:00
|
|
|
|
2025-03-04 04:06:16 -06:00
|
|
|
me.forge.Config.ConfigSave()
|
2025-03-02 04:13:10 -06:00
|
|
|
}
|
|
|
|
|
2025-03-02 07:49:30 -06:00
|
|
|
func doDisableUserW() {
|
|
|
|
me.argvCheckoutUser = false
|
|
|
|
me.modeUserW.Disable()
|
|
|
|
|
|
|
|
var count int
|
|
|
|
all := me.forge.Repos.SortByFullPath()
|
|
|
|
for all.Scan() {
|
|
|
|
repo := all.Next()
|
|
|
|
if !repo.IsLocalBranch(repo.GetUserBranchName()) {
|
|
|
|
// log.Info("repo doesn't have user branch", repo.GetGoPath())
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
count += 1
|
|
|
|
}
|
|
|
|
|
|
|
|
if count > 0 {
|
|
|
|
s := fmt.Sprintf("git delete %d user branches", count)
|
|
|
|
me.modeUserW.SetLabel(s)
|
|
|
|
me.modeUserW.Enable()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-02-21 16:10:33 -06:00
|
|
|
// this is the magic that generates a window directly from the protocol buffer
|
|
|
|
func makeStandardReposGrid(pb *gitpb.Repos) *gitpb.ReposTable {
|
|
|
|
t := pb.NewTable("testDirty")
|
|
|
|
sf := t.AddStringFunc("repo", func(r *gitpb.Repo) string {
|
|
|
|
return r.GetGoPath()
|
|
|
|
})
|
|
|
|
// t.Custom = func() {
|
|
|
|
// log.Info("close grid?")
|
|
|
|
// }
|
|
|
|
sf.Custom = func(r *gitpb.Repo) {
|
|
|
|
log.Info("do button click on", r.GetGoPath())
|
|
|
|
}
|
|
|
|
t.AddTimeFunc("age", func(repo *gitpb.Repo) time.Time {
|
|
|
|
return repo.NewestTime()
|
|
|
|
})
|
|
|
|
t.AddMasterVersion()
|
|
|
|
t.AddDevelVersion()
|
|
|
|
t.AddUserVersion()
|
|
|
|
t.AddCurrentBranchName()
|
|
|
|
t.AddState()
|
|
|
|
return t
|
|
|
|
}
|
|
|
|
|
2025-02-21 09:13:54 -06:00
|
|
|
// this is the magic that generates a window directly from the protocol buffer
|
2025-02-21 18:31:26 -06:00
|
|
|
func makeStandardReposWindow(title string, pb *gitpb.Repos) (*gitpb.ReposTable, *gui.Node) {
|
2025-02-21 16:35:21 -06:00
|
|
|
win := gadgets.RawBasicWindow(title)
|
|
|
|
win.Make()
|
|
|
|
win.Show()
|
|
|
|
win.Custom = func() {
|
|
|
|
// sets the hidden flag to false so Toggle() works
|
|
|
|
win.Hide()
|
2025-02-21 05:41:30 -06:00
|
|
|
}
|
2025-02-21 16:35:21 -06:00
|
|
|
box := win.Box().NewBox("bw vbox", false)
|
|
|
|
|
|
|
|
t := makeStandardReposGrid(pb)
|
|
|
|
t.SetParent(box)
|
2025-02-21 05:41:30 -06:00
|
|
|
t.ShowTable()
|
2025-02-21 18:31:26 -06:00
|
|
|
return t, box
|
2025-02-13 23:20:24 -06:00
|
|
|
}
|
|
|
|
|
2025-03-04 04:12:14 -06:00
|
|
|
func makeWritableWindow(pb *gitpb.Repos) (*gadgets.GenericWindow, *gitpb.ReposTable) {
|
|
|
|
win := gadgets.NewGenericWindow("Repos You have write access to", "Configure")
|
2025-02-24 11:00:08 -06:00
|
|
|
t := pb.NewTable("testForgeRepos")
|
|
|
|
t.NewUuid()
|
|
|
|
|
|
|
|
grid := win.Group.RawGrid()
|
|
|
|
grid.NewButton("git pull", func() {
|
|
|
|
log.Info("todo: run git pull on each repo")
|
|
|
|
})
|
|
|
|
|
|
|
|
grid.NewButton("do repos.ReScan()", func() {
|
|
|
|
t.Update()
|
|
|
|
})
|
|
|
|
|
|
|
|
tbox := win.Bottom.Box()
|
|
|
|
t.SetParent(tbox)
|
|
|
|
|
|
|
|
sf := t.AddStringFunc("repo", func(r *gitpb.Repo) string {
|
|
|
|
return r.GetGoPath()
|
|
|
|
})
|
|
|
|
sf.Custom = func(r *gitpb.Repo) {
|
|
|
|
log.Info("do button click on", r.GetGoPath())
|
|
|
|
}
|
|
|
|
t.AddTimeFunc("age", func(repo *gitpb.Repo) time.Time {
|
|
|
|
return repo.NewestTime()
|
|
|
|
})
|
|
|
|
t.AddMasterVersion()
|
|
|
|
t.AddDevelVersion()
|
|
|
|
t.AddUserVersion()
|
|
|
|
t.AddCurrentBranchName()
|
|
|
|
t.AddState()
|
|
|
|
t.ShowTable()
|
|
|
|
return win, t
|
|
|
|
}
|
|
|
|
|
2025-02-21 18:49:33 -06:00
|
|
|
func findMergeToDevel() *gitpb.Repos {
|
|
|
|
found := gitpb.NewRepos()
|
2025-02-13 23:46:11 -06:00
|
|
|
|
|
|
|
all := me.forge.Repos.SortByFullPath()
|
|
|
|
for all.Scan() {
|
|
|
|
repo := all.Next()
|
|
|
|
|
|
|
|
// this sees if user has patches for devel. If it does, add it to me.found
|
|
|
|
if repo.CountDiffObjects(repo.GetUserBranchName(), repo.GetDevelBranchName()) > 0 {
|
2025-02-21 18:49:33 -06:00
|
|
|
found.AppendByGoPath(repo)
|
2025-02-13 23:46:11 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
now := time.Now()
|
2025-02-21 18:49:33 -06:00
|
|
|
if found.Len() == 0 {
|
2025-02-13 23:46:11 -06:00
|
|
|
log.Info("nothing to merge with devel")
|
2025-02-21 18:49:33 -06:00
|
|
|
return found
|
2025-02-13 23:46:11 -06:00
|
|
|
}
|
2025-02-21 18:49:33 -06:00
|
|
|
// me.forge.PrintHumanTable(found)
|
2025-02-13 23:46:11 -06:00
|
|
|
|
|
|
|
// check for merges from devel
|
|
|
|
total, count, nope, _ := IsEverythingOnDevel()
|
|
|
|
log.Printf("devel branch check. %d total repos. (%d ok) (%d not on devel branch) (%s)\n", total, count, nope, shell.FormatDuration(time.Since(now)))
|
2025-02-21 18:49:33 -06:00
|
|
|
return found
|
2025-02-13 23:46:11 -06:00
|
|
|
}
|
2025-02-13 23:20:24 -06:00
|
|
|
func findMergeToMaster() {
|
|
|
|
me.found = new(gitpb.Repos)
|
|
|
|
|
|
|
|
all := me.forge.Repos.SortByFullPath()
|
|
|
|
for all.Scan() {
|
|
|
|
repo := all.Next()
|
|
|
|
if me.forge.Config.IsReadOnly(repo.GetGoPath()) {
|
|
|
|
continue
|
2025-02-13 22:52:10 -06:00
|
|
|
}
|
2025-02-13 23:38:22 -06:00
|
|
|
/*
|
|
|
|
if repo.IsDirty() {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if repo.GetMasterVersion() != repo.GetDevelVersion() {
|
|
|
|
me.found.AppendByGoPath(repo)
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
// this sees if devel is behind master. IT SHOULD NOT BE
|
|
|
|
if repo.CountDiffObjects(repo.GetMasterBranchName(), repo.GetDevelBranchName()) == 0 {
|
|
|
|
// everything is normal
|
|
|
|
} else {
|
|
|
|
repo.State = "DEVEL < MASTER"
|
|
|
|
log.Info("SERIOUS ERROR. DEVEL BRANCH IS BEHIND MASTER", repo.GetGoPath())
|
|
|
|
}
|
|
|
|
|
|
|
|
// this sees if devel has patches for master. If it does, add it to me.found
|
2025-02-13 23:46:11 -06:00
|
|
|
if repo.CountDiffObjects(repo.GetDevelBranchName(), repo.GetMasterBranchName()) > 0 {
|
2025-02-13 23:20:24 -06:00
|
|
|
me.found.AppendByGoPath(repo)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
now := time.Now()
|
|
|
|
if me.found.Len() == 0 {
|
|
|
|
log.Info("nothing to merge with master")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
me.forge.PrintHumanTable(me.found)
|
2025-02-13 22:52:10 -06:00
|
|
|
|
2025-02-13 23:20:24 -06:00
|
|
|
// check for merges from devel
|
|
|
|
total, count, nope, _ := IsEverythingOnMaster()
|
|
|
|
log.Printf("Master branch check. %d total repos. (%d ok) (%d not on master branch) (%s)\n", total, count, nope, shell.FormatDuration(time.Since(now)))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func mergeDevelToMaster(doit bool) {
|
|
|
|
findMergeToMaster()
|
|
|
|
|
|
|
|
if !doit {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
all := me.found.SortByFullPath()
|
|
|
|
for all.Scan() {
|
|
|
|
repo := all.Next()
|
|
|
|
log.Info("repo:", repo.GetGoPath())
|
|
|
|
if result, err := repo.MergeToMaster(); err == nil {
|
|
|
|
log.Warn("THINGS SEEM OK", repo.GetFullPath())
|
|
|
|
for _, line := range result.Stdout {
|
|
|
|
log.Warn("stdout:", line)
|
|
|
|
}
|
|
|
|
for _, line := range result.Stderr {
|
|
|
|
log.Warn("stderr:", line)
|
|
|
|
}
|
2025-02-13 22:52:10 -06:00
|
|
|
} else {
|
2025-02-13 23:20:24 -06:00
|
|
|
log.Warn("THINGS FAILED ", repo.GetFullPath())
|
|
|
|
log.Warn("err", err)
|
|
|
|
if result == nil {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
for _, line := range result.Stdout {
|
|
|
|
log.Warn("stdout:", line)
|
|
|
|
}
|
|
|
|
for _, line := range result.Stderr {
|
|
|
|
log.Warn("stderr:", line)
|
|
|
|
}
|
|
|
|
log.Warn("THINGS FAILED ", repo.GetFullPath())
|
|
|
|
break
|
2025-02-13 22:52:10 -06:00
|
|
|
}
|
2025-02-13 23:20:24 -06:00
|
|
|
me.forge.SetConfigSave(true)
|
|
|
|
// view.Update()
|
|
|
|
}
|
|
|
|
me.forge.ConfigSave()
|
|
|
|
}
|
2025-02-13 22:52:10 -06:00
|
|
|
|
2025-02-13 23:20:24 -06:00
|
|
|
func mergeUserToDevel(doit bool) {
|
2025-02-21 18:49:33 -06:00
|
|
|
found := findMergeToDevel()
|
2025-02-13 23:20:24 -06:00
|
|
|
|
|
|
|
if !doit {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2025-02-21 18:49:33 -06:00
|
|
|
all := found.SortByFullPath()
|
2025-02-13 23:20:24 -06:00
|
|
|
for all.Scan() {
|
|
|
|
repo := all.Next()
|
2025-02-18 09:39:30 -06:00
|
|
|
bruser := repo.GetUserBranchName()
|
|
|
|
brdevel := repo.GetDevelBranchName()
|
|
|
|
|
|
|
|
if repo.GetUserVersion() == "uerr" {
|
|
|
|
// no user branch
|
|
|
|
return
|
|
|
|
}
|
|
|
|
log.Info("trying", bruser, repo.GetUserVersion())
|
|
|
|
|
|
|
|
b1 := repo.CountDiffObjects(bruser, brdevel) // should be zero
|
|
|
|
if b1 == 0 {
|
|
|
|
// log.Info("User is already merged into Devel", repo.GetGoPath(), cmd)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
log.Info("merging user into devel repo:", repo.GetGoPath())
|
2025-02-13 23:20:24 -06:00
|
|
|
if result, err := repo.MergeToDevel(); err == nil {
|
|
|
|
log.Warn("THINGS SEEM OK", repo.GetFullPath())
|
|
|
|
for _, line := range result.Stdout {
|
|
|
|
log.Warn("stdout:", line)
|
|
|
|
}
|
|
|
|
for _, line := range result.Stderr {
|
|
|
|
log.Warn("stderr:", line)
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
log.Warn("THINGS FAILED ", repo.GetFullPath())
|
|
|
|
log.Warn("err", err)
|
|
|
|
if result == nil {
|
2025-02-13 22:52:10 -06:00
|
|
|
break
|
|
|
|
}
|
2025-02-13 23:20:24 -06:00
|
|
|
for _, line := range result.Stdout {
|
|
|
|
log.Warn("stdout:", line)
|
|
|
|
}
|
|
|
|
for _, line := range result.Stderr {
|
|
|
|
log.Warn("stderr:", line)
|
|
|
|
}
|
|
|
|
break
|
2025-02-13 22:52:10 -06:00
|
|
|
}
|
2025-02-13 23:20:24 -06:00
|
|
|
me.forge.SetConfigSave(true)
|
|
|
|
// view.Update()
|
|
|
|
}
|
|
|
|
me.forge.ConfigSave()
|
2024-12-05 12:29:47 -06:00
|
|
|
}
|