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-01-26 02:04:19 -06:00
|
|
|
"fmt"
|
2024-02-14 01:04:31 -06:00
|
|
|
"os"
|
|
|
|
"path/filepath"
|
2024-02-02 17:04:57 -06:00
|
|
|
"strings"
|
2024-01-26 02:04:19 -06:00
|
|
|
"time"
|
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-24 22:22:34 -06:00
|
|
|
me.allrepos = make(map[string]*repo)
|
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-01-30 14:05:22 -06:00
|
|
|
me.mainWindow = me.myGui.NewWindow("GUI release manager")
|
|
|
|
me.mainBox = me.mainWindow.NewBox("bw hbox", true)
|
|
|
|
|
|
|
|
globalDisplayOptions(me.mainBox)
|
|
|
|
|
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-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-01-19 18:37:27 -06:00
|
|
|
repoworld()
|
2024-01-20 17:17:48 -06:00
|
|
|
|
2024-02-09 11:50:16 -06:00
|
|
|
me.releaseReasonS = releaseReasonS
|
2024-02-05 15:06:02 -06:00
|
|
|
|
2024-02-17 14:21:05 -06:00
|
|
|
for i, repo := range me.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())
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
repo.status.UpdateNew()
|
2024-01-30 13:45:42 -06:00
|
|
|
repo.newScan()
|
2024-02-02 00:02:53 -06:00
|
|
|
|
|
|
|
if repo.String() == "go.wit.com/widget" {
|
2024-02-09 11:50:16 -06:00
|
|
|
repo.targetVersion.SetText("v" + widgetVersion)
|
2024-02-02 00:02:53 -06:00
|
|
|
} else {
|
2024-02-09 11:50:16 -06:00
|
|
|
repo.targetVersion.SetText("v" + releaseVersion)
|
2024-02-02 00:02:53 -06:00
|
|
|
}
|
2024-02-02 17:04:57 -06:00
|
|
|
if strings.HasPrefix(repo.String(), "go.wit.com/dev/") {
|
|
|
|
lasttag := repo.status.GetLastTagVersion()
|
|
|
|
repo.targetVersion.SetText(lasttag)
|
|
|
|
}
|
|
|
|
// if repo.String() == "go.wit.com/apps/guireleaser" {
|
2024-01-30 13:45:42 -06:00
|
|
|
}
|
2024-01-30 14:20:54 -06:00
|
|
|
log.Info("Creating the Release Window")
|
|
|
|
|
|
|
|
createReleaseBox(me.mainBox)
|
2024-02-14 16:09:44 -06:00
|
|
|
// createUnreleaseBox(me.mainBox)
|
2024-01-31 05:04:18 -06:00
|
|
|
|
2024-02-14 16:16:11 -06:00
|
|
|
for _, repo := range me.allrepos {
|
|
|
|
if repo.status.ReadOnly() {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if whitelist(repo.String()) {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if repo.status.CheckoutMaster() {
|
|
|
|
log.Warn("set master branch worked", repo.String())
|
|
|
|
repo.newScan()
|
|
|
|
} 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())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-31 05:04:18 -06:00
|
|
|
showHideRepos()
|
2024-01-30 14:20:54 -06:00
|
|
|
|
2024-01-30 13:59:40 -06:00
|
|
|
release.openrepo.Disable()
|
2024-01-30 13:45:42 -06:00
|
|
|
|
2024-01-26 02:04:19 -06:00
|
|
|
// scan repos every 30 seconds
|
|
|
|
// check every second for the checkbox changing
|
|
|
|
var i int = 60
|
2024-01-26 11:59:59 -06:00
|
|
|
myTicker(1*time.Second, "newScan()", func() {
|
2024-01-26 02:04:19 -06:00
|
|
|
i += 1
|
2024-01-26 11:59:59 -06:00
|
|
|
if !me.scanEveryMinute.Checked() {
|
2024-01-26 02:04:19 -06:00
|
|
|
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)
|
|
|
|
})
|
2024-01-09 01:16:00 -06:00
|
|
|
}
|