2024-01-09 01:16:00 -06:00
|
|
|
package main
|
|
|
|
|
2024-01-18 00:58:14 -06:00
|
|
|
import (
|
2024-01-15 08:11:08 -06:00
|
|
|
"embed"
|
2024-02-14 01:04:31 -06:00
|
|
|
"os"
|
|
|
|
"path/filepath"
|
2024-02-02 17:04:57 -06:00
|
|
|
"strings"
|
2024-01-09 10:21:58 -06:00
|
|
|
|
2024-01-18 05:03:04 -06:00
|
|
|
"go.wit.com/gui"
|
2024-02-14 01:04:31 -06:00
|
|
|
"go.wit.com/lib/gui/shell"
|
2024-02-09 11:50:16 -06:00
|
|
|
"go.wit.com/log"
|
2024-01-09 01:16:00 -06:00
|
|
|
)
|
|
|
|
|
2024-02-09 11:50:16 -06:00
|
|
|
// TODO: autocompute these in the gui
|
2024-02-14 01:04:31 -06:00
|
|
|
var releaseReasonS string
|
|
|
|
var releaseVersion string
|
|
|
|
var widgetVersion string
|
2024-02-09 11:50:16 -06:00
|
|
|
|
2024-01-15 21:11:28 -06:00
|
|
|
//go:embed resources/*
|
2024-01-15 08:11:08 -06:00
|
|
|
var resToolkit embed.FS
|
|
|
|
|
2024-01-09 01:16:00 -06:00
|
|
|
func main() {
|
2024-01-23 11:22:33 -06:00
|
|
|
me = new(autoType)
|
2024-01-18 05:03:04 -06:00
|
|
|
|
2024-02-14 01:04:31 -06:00
|
|
|
// TODO: autocompute these in the gui
|
|
|
|
releaseReasonS = os.Getenv("GUIRELEASE_REASON")
|
|
|
|
releaseVersion = os.Getenv("GUIRELEASE_VERSION")
|
|
|
|
widgetVersion = os.Getenv("GUIRELEASE_WIDGET")
|
|
|
|
|
|
|
|
if releaseVersion == "" {
|
|
|
|
log.Info("GUIRELEASE_VERSION not set")
|
|
|
|
os.Exit(0)
|
|
|
|
}
|
|
|
|
|
2024-01-18 05:03:04 -06:00
|
|
|
me.myGui = gui.New()
|
|
|
|
me.myGui.InitEmbed(resToolkit)
|
|
|
|
me.myGui.Default()
|
2024-01-09 01:16:00 -06:00
|
|
|
|
2024-02-18 15:09:04 -06:00
|
|
|
// our main window
|
2024-01-30 14:05:22 -06:00
|
|
|
me.mainWindow = me.myGui.NewWindow("GUI release manager")
|
|
|
|
me.mainBox = me.mainWindow.NewBox("bw hbox", true)
|
|
|
|
|
2024-02-18 15:09:04 -06:00
|
|
|
// the left side of the window options
|
2024-01-30 14:05:22 -06:00
|
|
|
globalDisplayOptions(me.mainBox)
|
|
|
|
|
2024-02-18 15:09:04 -06:00
|
|
|
// sanity check of things that might be around that mess
|
|
|
|
// up things later
|
2024-02-14 01:04:31 -06:00
|
|
|
// if you have a go.work file, you must delete it
|
|
|
|
// TODO: check for go.work files anywhere
|
|
|
|
homeDir, _ := os.UserHomeDir()
|
|
|
|
gowork := filepath.Join(homeDir, "go/src/go.work")
|
|
|
|
if shell.Exists(gowork) {
|
|
|
|
log.Info("go.work must be deleted")
|
|
|
|
os.Exit(0)
|
|
|
|
}
|
|
|
|
|
2024-02-18 15:09:04 -06:00
|
|
|
// sanity check of things that might be around that mess
|
|
|
|
// up things later
|
|
|
|
// check to make sure we have a go.sum here
|
2024-02-14 13:44:24 -06:00
|
|
|
gosum := filepath.Join(homeDir, "go/src/go.wit.com/apps/guireleaser/go.sum")
|
2024-02-14 16:06:52 -06:00
|
|
|
if !shell.Exists(gosum) {
|
2024-02-14 13:44:24 -06:00
|
|
|
log.Info("go.sum must exist here")
|
|
|
|
os.Exit(0)
|
|
|
|
}
|
|
|
|
|
2024-02-18 15:09:04 -06:00
|
|
|
// save the ENV var here
|
2024-02-09 11:50:16 -06:00
|
|
|
me.releaseReasonS = releaseReasonS
|
2024-02-05 15:06:02 -06:00
|
|
|
|
2024-02-18 15:09:04 -06:00
|
|
|
me.repos = makeRepoView()
|
|
|
|
|
|
|
|
// go through and set the target versions for each repo
|
|
|
|
// todo: add sanity checking in repolist to verify these and/or autocompute them
|
|
|
|
// for now, just don't be stupid when you set your ENV vars
|
|
|
|
// widget I versioned early before I knew what the hell this would mean and can
|
|
|
|
// not be down versioned because that's not how GO versioning works. Once you
|
|
|
|
// set the version for a path, it's set in stone forever. (smart system!)
|
|
|
|
// we could rename go.wit.com/widget to go.wit.com/newwidget and restart the versioning
|
|
|
|
// system, but that's rediculous and this servers to always remind me to never make this mistake again
|
|
|
|
for i, repo := range me.repos.View.AllRepos() {
|
2024-02-17 14:21:05 -06:00
|
|
|
if repo == nil {
|
|
|
|
log.Info("initial scan i = nil", i)
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2024-02-18 15:09:04 -06:00
|
|
|
log.Info("initial scan repo", repo.Name())
|
|
|
|
if repo.Status == nil {
|
|
|
|
log.Info("repo.status == nil", repo.Name())
|
2024-02-17 14:21:05 -06:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2024-02-18 15:09:04 -06:00
|
|
|
if repo.GoPath() == "go.wit.com/widget" {
|
|
|
|
repo.Status.SetTargetVersion("v" + widgetVersion)
|
2024-02-02 00:02:53 -06:00
|
|
|
} else {
|
2024-02-18 15:09:04 -06:00
|
|
|
repo.Status.SetTargetVersion("v" + releaseVersion)
|
2024-02-02 00:02:53 -06:00
|
|
|
}
|
2024-02-18 15:09:04 -06:00
|
|
|
if strings.HasPrefix(repo.GoPath(), "go.wit.com/dev/") {
|
|
|
|
lasttag := repo.Status.GetLastTagVersion()
|
|
|
|
repo.Status.SetTargetVersion(lasttag)
|
2024-02-02 17:04:57 -06:00
|
|
|
}
|
2024-01-30 13:45:42 -06:00
|
|
|
}
|
2024-01-30 14:20:54 -06:00
|
|
|
log.Info("Creating the Release Window")
|
|
|
|
|
2024-02-18 15:09:04 -06:00
|
|
|
// create the right side of the main window
|
2024-01-30 14:20:54 -06:00
|
|
|
createReleaseBox(me.mainBox)
|
2024-01-31 05:04:18 -06:00
|
|
|
|
2024-02-18 15:09:04 -06:00
|
|
|
|
|
|
|
// start the initail scan and make sure each repo is set
|
|
|
|
// to the master branch
|
|
|
|
for _, repo := range me.repos.View.AllRepos() {
|
|
|
|
if repo.ReadOnly() {
|
2024-02-14 16:16:11 -06:00
|
|
|
continue
|
|
|
|
}
|
2024-02-18 15:09:04 -06:00
|
|
|
if whitelist(repo.GoPath()) {
|
2024-02-14 16:16:11 -06:00
|
|
|
continue
|
|
|
|
}
|
2024-02-18 15:09:04 -06:00
|
|
|
if repo.Status.CheckoutMaster() {
|
|
|
|
log.Warn("git checkout master branch worked", repo.Name())
|
|
|
|
repo.Status.UpdateNew()
|
2024-02-14 16:16:11 -06:00
|
|
|
} else {
|
2024-02-18 15:09:04 -06:00
|
|
|
repo.Status.UpdateNew()
|
|
|
|
log.Warn("git checkout master branch failed", repo.Name())
|
2024-02-14 16:16:11 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-18 15:09:04 -06:00
|
|
|
// disable the open repo button. this isn't really important
|
|
|
|
// but does indicates the app (and toolkit) is working
|
|
|
|
// this can be removed later, but in these early days, I'm using this
|
|
|
|
// tool to release the code for this app, the gui and the gui toolkits
|
|
|
|
// and sometimes they lie, don't display stuff, don't even disable things
|
|
|
|
// so I can't trust even what I see. It's complicated right now still.
|
2024-01-30 13:59:40 -06:00
|
|
|
release.openrepo.Disable()
|
2024-01-30 13:45:42 -06:00
|
|
|
|
2024-02-18 15:09:04 -06:00
|
|
|
// I don't know what this is autotypist thing?
|
|
|
|
// globalResetOptions(me.mainbox)
|
|
|
|
|
|
|
|
// hopefully this is the list of all the golang packages and only the GUI golang packages
|
|
|
|
me.repos = makeRepoView()
|
|
|
|
|
|
|
|
// parse config file and scan for .git repos
|
|
|
|
me.repos.initRepoList()
|
|
|
|
|
|
|
|
// reads in the State of all the repos
|
|
|
|
// TODO: should not really be necessary directly after init()
|
|
|
|
me.repos.View.ScanRepositories()
|
|
|
|
|
|
|
|
me.Enable()
|
|
|
|
|
|
|
|
// intermittently scans the status indefinitly
|
|
|
|
me.repos.View.Watchdog(func() {
|
|
|
|
log.Info("In main()")
|
|
|
|
// processing is done. update the repo summary box
|
|
|
|
// me.summary.Update()
|
2024-01-26 02:04:19 -06:00
|
|
|
})
|
2024-01-09 01:16:00 -06:00
|
|
|
}
|