2025-02-01 11:55:17 -06:00
|
|
|
// Copyright 2025 WIT.COM Inc Licensed 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-01-19 02:56:48 -06:00
|
|
|
"os"
|
2025-01-20 02:50:07 -06:00
|
|
|
"os/user"
|
|
|
|
"path/filepath"
|
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"
|
|
|
|
"go.wit.com/lib/gadgets"
|
2025-01-30 18:46:35 -06:00
|
|
|
"go.wit.com/lib/gui/shell"
|
2024-12-05 12:29:47 -06:00
|
|
|
"go.wit.com/log"
|
|
|
|
)
|
|
|
|
|
2025-01-08 04:07:33 -06:00
|
|
|
func debug() {
|
|
|
|
log.Info("cmd line --debugger == true")
|
2025-01-30 07:12:47 -06:00
|
|
|
func() {
|
|
|
|
for {
|
|
|
|
log.Sleep(30)
|
|
|
|
log.Info("cmd line --debugger == true")
|
|
|
|
// debugger.DebugWindow()
|
|
|
|
}
|
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-01-30 07:30:04 -06:00
|
|
|
mainWindow := gadgets.RawBasicWindow("Forge: (this kinda works sometimes)")
|
|
|
|
mainWindow.Make()
|
|
|
|
mainWindow.Show()
|
|
|
|
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
|
|
|
// this is just interesting to see how fast it is on various boxes
|
|
|
|
// and with how many repos you are working with. On my current laptop
|
|
|
|
// I have 320 repos and when I'm using it and most things are in memory
|
2025-01-30 19:00:57 -06:00
|
|
|
// cache, it took: rill repos.Reload() took (2ms)
|
|
|
|
// which is hard to believe when my ~/go/src is 13G with 424266 files
|
|
|
|
// nevermind, there must be something wrong with the code right now
|
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-01-30 07:30:04 -06:00
|
|
|
func drawWindow(win *gadgets.BasicWindow) {
|
2025-01-30 10:10:02 -06:00
|
|
|
var reposWin *repoWindow // this is the handle to the repo window
|
|
|
|
|
2025-01-30 07:30:04 -06:00
|
|
|
box := win.Box()
|
|
|
|
|
|
|
|
vbox := box.NewVerticalBox("BOX2")
|
|
|
|
|
2025-01-20 02:50:07 -06:00
|
|
|
group1 := vbox.NewGroup("Forge Settings")
|
|
|
|
grid := group1.NewGrid("buildOptions", 0, 0)
|
|
|
|
|
|
|
|
// me.autoWorkingPwd = gadgets.NewOneLiner(grid, "working directory (pwd)")
|
2025-01-31 08:49:19 -06:00
|
|
|
me.goSrcPwd = gadgets.NewOneLiner(grid, "repo src home")
|
2025-01-20 02:50:07 -06:00
|
|
|
grid.NextRow()
|
|
|
|
|
|
|
|
usr, _ := user.Current()
|
|
|
|
homeDir, err := os.UserHomeDir()
|
|
|
|
if err != nil {
|
|
|
|
log.Warn("Error getting home directory:", err)
|
|
|
|
homeDir = "/home/autotypist"
|
|
|
|
}
|
|
|
|
srcDir := filepath.Join(homeDir, "go/src")
|
|
|
|
me.goSrcPwd.SetText(srcDir)
|
|
|
|
|
|
|
|
// 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)
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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-01-30 07:21:08 -06:00
|
|
|
me.setBranchB = grid.NewButton("git checkout", func() {
|
2025-01-30 10:10:02 -06:00
|
|
|
if reposWin != nil {
|
|
|
|
reposWin.Hide()
|
|
|
|
}
|
2025-01-20 02:50:07 -06:00
|
|
|
targetName := me.newBranch.String()
|
|
|
|
log.Warn("setting all branches to", targetName)
|
|
|
|
if targetName == "devel" {
|
|
|
|
if err := doAllCheckoutDevel(); err != nil {
|
|
|
|
log.Info("switching to devel branches failed")
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if targetName == "master" {
|
|
|
|
if err := doAllCheckoutMaster(); err != nil {
|
|
|
|
log.Info("switching to master branches failed")
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
// just assume user
|
|
|
|
if err := doAllCheckoutUser(); err != nil {
|
|
|
|
log.Info("switching to user branches failed")
|
|
|
|
}
|
|
|
|
})
|
2025-01-30 07:21:08 -06:00
|
|
|
me.newBranch = grid.NewDropdown()
|
2025-01-20 02:50:07 -06:00
|
|
|
me.newBranch.AddText("master")
|
|
|
|
me.newBranch.AddText("devel")
|
|
|
|
me.newBranch.AddText(usr.Username)
|
|
|
|
me.newBranch.SetText(usr.Username)
|
|
|
|
|
|
|
|
// checking this will automatically make the branches off of devel
|
2025-01-30 07:21:08 -06:00
|
|
|
me.autoCreateBranches = grid.NewCheckbox("auto create branches").SetChecked(true)
|
2025-01-20 02:50:07 -06:00
|
|
|
grid.NextRow()
|
|
|
|
|
|
|
|
grid.NewButton("Repo Window", func() {
|
2025-01-30 07:12:47 -06:00
|
|
|
if reposWin != nil {
|
|
|
|
if reposWin.Hidden() {
|
|
|
|
reposWin.Show()
|
|
|
|
} else {
|
|
|
|
reposWin.Hide()
|
|
|
|
}
|
|
|
|
return
|
2025-01-20 02:50:07 -06:00
|
|
|
}
|
2025-01-30 07:12:47 -06:00
|
|
|
reposWin = makeRepoView()
|
|
|
|
reposWin.Show()
|
2025-01-20 02:50:07 -06:00
|
|
|
})
|
2025-01-30 07:12:47 -06:00
|
|
|
|
|
|
|
var patchWin *patchesWindow
|
|
|
|
|
2025-01-20 02:50:07 -06:00
|
|
|
grid.NewButton("Patches Window", func() {
|
2025-01-30 07:12:47 -06:00
|
|
|
if patchWin != nil {
|
|
|
|
patchWin.Toggle()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
patchWin = new(patchesWindow)
|
|
|
|
patchWin.initWindow()
|
|
|
|
patchWin.Show()
|
2024-12-05 12:29:47 -06:00
|
|
|
})
|
2025-01-30 07:21:08 -06:00
|
|
|
|
|
|
|
grid.NewButton("forge ConfigSave()", func() {
|
|
|
|
me.forge.ConfigSave()
|
|
|
|
})
|
2024-12-05 12:29:47 -06:00
|
|
|
}
|