diff options
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 125 |
1 files changed, 66 insertions, 59 deletions
@@ -2,11 +2,9 @@ package main import ( "embed" - "fmt" "os" "path/filepath" "strings" - "time" "go.wit.com/gui" "go.wit.com/lib/gui/shell" @@ -23,7 +21,6 @@ var resToolkit embed.FS func main() { me = new(autoType) - me.allrepos = make(map[string]*repo) // TODO: autocompute these in the gui releaseReasonS = os.Getenv("GUIRELEASE_REASON") @@ -39,11 +36,15 @@ func main() { me.myGui.InitEmbed(resToolkit) me.myGui.Default() + // our main window me.mainWindow = me.myGui.NewWindow("GUI release manager") me.mainBox = me.mainWindow.NewBox("bw hbox", true) + // the left side of the window options globalDisplayOptions(me.mainBox) + // sanity check of things that might be around that mess + // up things later // if you have a go.work file, you must delete it // TODO: check for go.work files anywhere homeDir, _ := os.UserHomeDir() @@ -53,95 +54,101 @@ func main() { os.Exit(0) } + // sanity check of things that might be around that mess + // up things later + // check to make sure we have a go.sum here gosum := filepath.Join(homeDir, "go/src/go.wit.com/apps/guireleaser/go.sum") if !shell.Exists(gosum) { log.Info("go.sum must exist here") os.Exit(0) } - repoworld() - + // save the ENV var here me.releaseReasonS = releaseReasonS - for i, repo := range me.allrepos { + 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() { if repo == nil { log.Info("initial scan i = nil", i) continue } - log.Info("initial scan repo", repo.String()) - if repo.status == nil { - log.Info("repo.status == nil", repo.String()) + log.Info("initial scan repo", repo.Name()) + if repo.Status == nil { + log.Info("repo.status == nil", repo.Name()) continue } - repo.status.UpdateNew() - repo.newScan() - - if repo.String() == "go.wit.com/widget" { - repo.targetVersion.SetText("v" + widgetVersion) + if repo.GoPath() == "go.wit.com/widget" { + repo.Status.SetTargetVersion("v" + widgetVersion) } else { - repo.targetVersion.SetText("v" + releaseVersion) + repo.Status.SetTargetVersion("v" + releaseVersion) } - if strings.HasPrefix(repo.String(), "go.wit.com/dev/") { - lasttag := repo.status.GetLastTagVersion() - repo.targetVersion.SetText(lasttag) + if strings.HasPrefix(repo.GoPath(), "go.wit.com/dev/") { + lasttag := repo.Status.GetLastTagVersion() + repo.Status.SetTargetVersion(lasttag) } - // if repo.String() == "go.wit.com/apps/guireleaser" { } log.Info("Creating the Release Window") + // create the right side of the main window createReleaseBox(me.mainBox) - // createUnreleaseBox(me.mainBox) - for _, repo := range me.allrepos { - if repo.status.ReadOnly() { + + // 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() { continue } - if whitelist(repo.String()) { + if whitelist(repo.GoPath()) { continue } - if repo.status.CheckoutMaster() { - log.Warn("set master branch worked", repo.String()) - repo.newScan() + if repo.Status.CheckoutMaster() { + log.Warn("git checkout master branch worked", repo.Name()) + repo.Status.UpdateNew() } else { - repo.newScan() - log.Warn("set master branch failed", repo.String()) - log.Warn("set master branch failed", repo.String()) - log.Warn("set master branch failed", repo.String()) + repo.Status.UpdateNew() + log.Warn("git checkout master branch failed", repo.Name()) } } - showHideRepos() - + // 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. release.openrepo.Disable() - // scan repos every 30 seconds - // check every second for the checkbox changing - var i int = 60 - myTicker(1*time.Second, "newScan()", func() { - i += 1 - if !me.scanEveryMinute.Checked() { - if i < 60 { - i = 60 - } - // print every 13 seconds - if i%13 == 0 { - log.Info("Not auto scanning", i) - } - return - } - if i < 60 { - return - } - i = 0 - duration := timeFunction(func() { - scanGoSum() - for _, repo := range me.allrepos { - repo.newScan() - } - }) - s := fmt.Sprint(duration) - me.autoWorkingPwd.SetText(s) + // 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() }) } |
