guireleaser builds again

This commit is contained in:
Jeff Carr 2024-02-18 15:09:04 -06:00
parent bbc78159fe
commit 08c7765cc7
14 changed files with 470 additions and 638 deletions

View File

@ -1,4 +1,4 @@
all:
all: build
./guireleaser
stderr: build
@ -14,7 +14,7 @@ build:
echo "build it!"
-rm resources/*.so
cp -a ~/go/src/go.wit.com/toolkits/*.so resources/
go build -v -x
GO111MODULE=off go build -v -x
install:
rm -f ~/go/src/go.wit.com/toolkits/*.so

View File

@ -29,22 +29,22 @@ func CheckReady() bool {
log.Info("find the next repo first")
return false
}
goSumS := release.current.getGoSumStatus()
dirtyS := release.current.dirtyLabel.String()
lastS := release.current.status.GetLastTagVersion()
currentS := release.current.status.GetCurrentBranchVersion()
goSumS := release.current.Status.GetGoSumStatus()
dirtyS := release.current.State()
lastS := release.current.Status.GetLastTagVersion()
currentS := release.current.Status.GetCurrentBranchVersion()
var targetS string
targetS = release.version.String()
log.Info("repo:", release.current.String(), goSumS, dirtyS, lastS, currentS, targetS)
log.Info("repo:", release.current.State(), goSumS, dirtyS, lastS, currentS, targetS)
if goSumS == "RELEASED" {
return true
}
if goSumS == "PRIMATIVE" {
if targetS == lastS {
release.current.setGoSumStatus("RELEASED")
release.current.Status.SetGoSumStatus("RELEASED")
}
return true
}
@ -53,45 +53,45 @@ func CheckReady() bool {
}
if goSumS == "READY" {
if targetS == lastS {
release.current.setGoSumStatus("RELEASED")
release.current.Status.SetGoSumStatus("RELEASED")
return true
}
if lastS == currentS {
release.current.setGoSumStatus("UNRELEASED")
release.current.Status.SetGoSumStatus("UNRELEASED")
}
return true
}
release.current.setGoSumStatus("NOT READY")
if release.current.status.ReadOnly() {
release.current.Status.SetGoSumStatus("NOT READY")
if release.current.Status.ReadOnly() {
log.Info("\trepo is read only")
return false
}
if targetS == lastS {
log.Info("\trepo is already done", lastS, "=", targetS)
release.current.setGoSumStatus("READY")
release.current.Status.SetGoSumStatus("READY")
return true
}
if lastS == currentS {
log.Info("\trepo is already done", lastS, "=", targetS)
release.current.setGoSumStatus("READY")
release.current.Status.SetGoSumStatus("READY")
return true
}
if goSumS == "BAD" {
log.Info("\trepo is ready", release.current.String(), "BAD == BAD")
log.Info("\trepo is ready", release.current.State(), "BAD == BAD")
} else {
log.Info("\trepo is ready maybe", release.current.String(), "BAD !=", goSumS)
log.Info("\trepo is ready maybe", release.current.State(), "BAD !=", goSumS)
}
if release.current.status.CheckDirty() {
if release.current.Status.CheckDirty() {
log.Info("\trepo is dirty")
return false
} else {
log.Info("\trepo is ready", release.current.String(), "not dirty")
log.Info("\trepo is ready", release.current.State(), "not dirty")
}
fullpath := filepath.Join(me.goSrcPwd.String(), release.current.String())
fullpath := filepath.Join(me.goSrcPwd.String(), release.current.State())
testf := filepath.Join(fullpath, "go.mod")
if Exists(testf) {
@ -113,14 +113,14 @@ func CheckReady() bool {
// final checks here
if dirtyS == "unchanged" {
log.Info("\trepo is ready", release.current.String(), "unchanged")
log.Info("\trepo is ready", release.current.Name(), "unchanged")
} else {
log.Info("\trepo is not ready", dirtyS, "!= 'unchanged'")
return false
}
curName := release.current.status.GetCurrentBranchName()
mName := release.current.status.GetMasterBranchName()
curName := release.current.Status.GetCurrentBranchName()
mName := release.current.Status.GetMasterBranchName()
if curName == mName {
log.Info("\trepo is ready working from main branch", curName, "=", mName)
@ -129,7 +129,7 @@ func CheckReady() bool {
return false
}
release.current.setGoSumStatus("READY")
release.current.Status.SetGoSumStatus("READY")
return true
}

View File

@ -11,7 +11,7 @@ import (
)
func doRelease() bool {
log.Info("doRelease() on", release.current.String())
log.Info("doRelease() on", release.current.Name())
// double check release version logic
if release.releaseVersionB.String() != "release version "+release.version.String() {
log.Warn("something went wrong with the release.version:", release.version.String())
@ -23,9 +23,9 @@ func doRelease() bool {
log.Warn("version does not start with v.", release.version.String())
return false
}
switch release.status.String() {
switch release.current.Status.GetGoSumStatus() {
case "PRIMATIVE":
log.Warn("can do PRIMATIVE", release.version.String())
log.Warn("can do PRIMATIVE", release.current.Name())
case "GOOD":
log.Warn("GOOD. lots of go.sum checks passed", release.version.String())
case "manually chosen":
@ -41,21 +41,21 @@ func doRelease() bool {
log.Sleep(10)
*/
default:
log.Warn("what is this?", release.version.String(), release.status.String())
log.Warn("what is this?", release.version.String(), release.current.Name())
return false
}
if release.current.status.ReadOnly() {
if release.current.Status.ReadOnly() {
log.Info("sorry, it's read-only")
return true
}
if release.current.status.CheckDirty() {
if release.current.Status.CheckDirty() {
log.Info("sorry, it's still dirty")
return false
}
curName := release.current.status.GetCurrentBranchName()
mName := release.current.status.GetMasterBranchName()
curName := release.current.Status.GetCurrentBranchName()
mName := release.current.Status.GetMasterBranchName()
if curName != mName {
log.Info("\trepo is not working from main branch", curName, "!=", mName)
return false
@ -65,7 +65,7 @@ func doRelease() bool {
var all [][]string
all = append(all, []string{"git", "add", "-f", "go.mod"})
if release.current.status.CheckPrimativeGoMod() {
if release.current.Status.CheckPrimativeGoMod() {
// don't add go.sum here. TODO: check for go.sum file and fail
} else {
all = append(all, []string{"git", "add", "-f", "go.sum"})
@ -75,7 +75,7 @@ func doRelease() bool {
all = append(all, []string{"git", "tag", "-m", me.releaseReasonS, release.version.String()})
all = append(all, []string{"git", "push", "origin", release.version.String()})
if !release.current.status.DoAll(all) {
if !release.current.Status.DoAll(all) {
log.Info("failed to make new release", release.version.String())
return false
}
@ -88,11 +88,11 @@ func doRelease() bool {
}
log.Info("PUBLISH OK")
release.current.setGoSumStatus("RELEASED")
release.current.Status.SetGoSumStatus("RELEASED")
// unwind and re-tag. Now that the go.mod and go.sum are published, revert
// to the development branch
if !release.current.status.RevertMasterToDevel() {
if !release.current.Status.RevertMasterToDevel() {
log.Info("Revert Failed")
return false
}
@ -104,27 +104,21 @@ func doRelease() bool {
retag = append(retag, []string{"git", "tag", "-m", me.releaseReasonS, release.version.String()})
retag = append(retag, []string{"git", "push", "origin", release.version.String()})
if !release.current.status.DoAll(retag) {
if !release.current.Status.DoAll(retag) {
log.Info("retag failed")
return false
}
log.Info("EVERYTHING OK. RERELEASED", release.current.String())
log.Info("EVERYTHING OK. RERELEASED", release.current.Name())
// update the package versions used for checking go.sum validity
release.current.status.UpdateNew()
cbname := release.current.status.GetCurrentBranchName()
cbversion := release.current.status.GetCurrentBranchVersion()
lasttag := release.current.status.GetLastTagVersion()
// update the values in the GUI
release.current.lastTag.SetLabel(lasttag)
release.current.vLabel.SetLabel(cbname + " " + cbversion)
release.current.Status.UpdateNew()
// attempt to find another repo to release
if !doReleaseFindNext() {
log.Info("doReleaseFindNext() could not find a new")
return false
}
log.Info("GOOD TO RUN ANOTHER DAY ON:", release.current.String())
log.Info("GOOD TO RUN ANOTHER DAY ON:", release.current.Name())
return true
}
@ -137,14 +131,14 @@ func doReleaseFindNext() bool {
log.Info("findNextDirty() could not find anything")
return false
}
release.current.status.CheckSafeGoSumRemake()
if release.current.status.MakeRedomod() {
release.current.Status.CheckSafeGoSumRemake()
if release.current.Status.MakeRedomod() {
log.Info("Redo mod ok")
} else {
log.Info("go mod tidy not ok")
return false
}
if ok, _ := release.current.status.CheckGoSum(); ok {
if ok, _ := release.current.Status.CheckGoSum(); ok {
log.Info("repo has go.sum requirements that are clean")
// release.current.setGoSumStatus("CLEAN")
release.status.SetValue("GOOD")
@ -158,7 +152,7 @@ func doReleaseFindNext() bool {
// this pulls the new tag from the golang package repository
// to insert the new version
func doPublishVersion() bool {
gopath := release.current.String()
gopath := release.current.GoPath()
cmd := []string{"go", "get", "-v", gopath + "@" + release.version.String()}
log.Info("SHOULD RUN cmd HERE:", cmd)
@ -171,11 +165,11 @@ func doPublishVersion() bool {
gosum := filepath.Join(homeDir, "go/src/go.wit.com/apps/guireleaser/go.sum")
if !shell.Exists(gosum) {
log.Info("go.sum must exist here")
release.guireleaser.status.MakeRedomod()
release.guireleaser.Status.MakeRedomod()
}
os.Unsetenv("GO111MODULE")
log.Info("TRYING TO SELF UPDATE HERE. cmd =", cmd)
err, out := release.guireleaser.status.RunCmd(cmd)
err, out := release.guireleaser.Status.RunCmd(cmd)
if gopath == "go.wit.com/apps/guireleaser" {
// ignore errors on updating myself
log.Info("IGNORE SELF UPDATE ERROR. cmd =", cmd)
@ -184,7 +178,7 @@ func doPublishVersion() bool {
if err == nil {
log.Info("SELF UPDATE OK. out =", out)
log.Info("SELF UPDATE WORKED")
release.current.setGoSumStatus("RELEASED")
release.current.Status.SetGoSumStatus("RELEASED")
return true
}
return false

View File

@ -11,21 +11,21 @@ import (
)
func showHideRepos() {
for _, repo := range me.allrepos {
for _, repo := range me.repos.View.AllRepos() {
if me.autoHideReadOnly.Checked() {
if repo.status.ReadOnly() {
if repo.Status.ReadOnly() {
repo.Hide()
continue
}
}
if me.autoHidePerfect.Checked() {
if repo.dirtyLabel.String() == "PERFECT" {
if repo.State() == "PERFECT" {
repo.Hide()
continue
}
}
if me.autoReleased.Checked() {
if repo.getGoSumStatus() == "RELEASED" {
if repo.Status.GetGoSumStatus() == "RELEASED" {
repo.Hide()
continue
}
@ -35,14 +35,14 @@ func showHideRepos() {
}
func globalDisplayShow() {
for _, repo := range me.allrepos {
for _, repo := range me.repos.View.AllRepos() {
if me.autoHideReadOnly.Checked() {
if repo.status.ReadOnly() {
if repo.Status.ReadOnly() {
continue
}
}
if me.autoHidePerfect.Checked() {
if repo.dirtyLabel.String() == "PERFECT" {
if repo.State() == "PERFECT" {
continue
}
}
@ -56,20 +56,19 @@ func globalDisplayOptions(box *gui.Node) {
group1 := vbox.NewGroup("Global Display Options")
group1.NewButton("Show Repository Window", func() {
if reposwin.Hidden() {
log.Info("showing reposwin")
showHideRepos()
// have to run this twice for now
scanForReady()
scanForReady()
reposwin.Show()
findNextDirty("")
// double check the found next repo
fullDoubleCheckFix()
if me.repos.Hidden() {
me.repos.Show()
} else {
log.Info("hiding reposwin")
reposwin.Hide()
me.repos.Hide()
}
log.Info("showing reposwin")
showHideRepos()
// have to run this twice for now
// scanForReady()
// scanForReady()
// findNextDirty("")
// double check the found next repo
// fullDoubleCheckFix()
})
me.autoHideReadOnly = group1.NewCheckbox("Hide read-only repos").SetChecked(true)
@ -93,13 +92,13 @@ func globalDisplayOptions(box *gui.Node) {
me.autoReleased = group1.NewCheckbox("Hide RELEASED repos").SetChecked(false)
me.autoReleased.Custom = func() {
if me.autoReleased.Checked() {
for _, repo := range me.allrepos {
if repo.getGoSumStatus() == "RELEASED" {
for _, repo := range me.repos.View.AllRepos() {
if repo.Status.GetGoSumStatus() == "RELEASED" {
repo.Hide()
}
}
} else {
for _, repo := range me.allrepos {
for _, repo := range me.repos.View.AllRepos() {
repo.Show()
}
}
@ -111,21 +110,21 @@ func globalDisplayOptions(box *gui.Node) {
me.setBranchesToMasterB = group1.NewButton("set all branches to master", func() {
me.Disable()
for _, repo := range me.allrepos {
if repo.status.ReadOnly() {
for _, repo := range me.repos.View.AllRepos() {
if repo.Status.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("set 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("set master branch failed", repo.Name())
log.Warn("set master branch failed", repo.Name())
log.Warn("set master branch failed", repo.Name())
}
}
me.Enable()
@ -137,15 +136,15 @@ func globalDisplayOptions(box *gui.Node) {
os.Unsetenv("GO111MODULE")
longB.Disable()
me.Disable()
for _, repo := range me.allrepos {
if whitelist(repo.String()) {
for _, repo := range me.repos.View.AllRepos() {
if whitelist(repo.GoPath()) {
continue
}
if repo.status.ReadOnly() {
if repo.Status.ReadOnly() {
continue
}
if repo.status.MakeRedomod() {
log.Info("redo go.sum failed on", repo.String())
if repo.Status.MakeRedomod() {
log.Info("redo go.sum failed on", repo.Name())
// me.Enable()
// longB.Enable()
// longB.SetLabel("FAILED")
@ -160,54 +159,54 @@ func globalDisplayOptions(box *gui.Node) {
group1.NewButton("rm -f go.mod go.sum", func() {
me.Disable()
for _, repo := range me.allrepos {
if whitelist(repo.String()) {
for _, repo := range me.repos.View.AllRepos() {
if whitelist(repo.GoPath()) {
continue
}
if repo.status.ReadOnly() {
if repo.Status.ReadOnly() {
continue
}
repo.status.RunCmd([]string{"rm", "-f", "go.mod", "go.sum"})
repo.Status.RunCmd([]string{"rm", "-f", "go.mod", "go.sum"})
}
me.Enable()
})
group1.NewButton("git reset --hard", func() {
me.Disable()
for _, repo := range me.allrepos {
if whitelist(repo.String()) {
log.Warn("skipping whitelist", repo.String())
for _, repo := range me.repos.View.AllRepos() {
if whitelist(repo.GoPath()) {
log.Warn("skipping whitelist", repo.Name())
continue
}
log.Warn("running git reset --hard", repo.String())
repo.status.RunCmd([]string{"git", "reset", "--hard"})
log.Warn("running git reset --hard", repo.Name())
repo.Status.RunCmd([]string{"git", "reset", "--hard"})
}
me.Enable()
})
group1.NewButton("git ls-files |grep go.mod", func() {
// var all []string
for _, repo := range me.allrepos {
log.Info("repo:", repo.String())
if repo.status.ReadOnly() {
for _, repo := range me.repos.View.AllRepos() {
log.Info("repo:", repo.Name())
if repo.Status.ReadOnly() {
continue
}
if whitelist(repo.String()) {
log.Warn("skipping whitelist", repo.String())
if whitelist(repo.GoPath()) {
log.Warn("skipping whitelist", repo.GoPath())
continue
}
good, files := repo.status.GitLsFiles()
good, files := repo.Status.GitLsFiles()
if !good {
log.Warn("Something went wrong", repo.String())
log.Warn("Something went wrong", repo.GoPath())
continue
}
for _, filename := range strings.Split(files, "\n") {
log.Info("\tfile", filename)
if filename == "go.mod" {
log.Info("Found go.mod. does version match release version?")
log.Info(repo.lastTag.String(), "vs", repo.targetVersion.String())
if repo.lastTag.String() != repo.targetVersion.String() {
log.Info(repo.lastTag.String(), "vs", repo.targetVersion.String())
log.Info(repo.Status.GetLastTagVersion(), "vs", repo.Status.GetTargetVersion())
if repo.Status.GetLastTagVersion() != repo.Status.GetTargetVersion() {
log.Info(repo.Status.GetLastTagVersion(), "vs", repo.Status.GetTargetVersion())
log.Info("Found go.sum. version mismatch")
setCurrentRepo(repo, "VERY BROKEN", "rewind go.mod commit")
return
@ -215,9 +214,9 @@ func globalDisplayOptions(box *gui.Node) {
}
if filename == "go.sum" {
log.Info("Found go.sum. does version match release version?")
log.Info(repo.lastTag.String(), "vs", repo.targetVersion.String())
if repo.lastTag.String() != repo.targetVersion.String() {
log.Info(repo.lastTag.String(), "vs", repo.targetVersion.String())
log.Info(repo.Status.GetLastTagVersion(), "vs", repo.Status.GetTargetVersion())
if repo.Status.GetLastTagVersion() != repo.Status.GetTargetVersion() {
log.Info(repo.Status.GetLastTagVersion(), "vs", repo.Status.GetTargetVersion())
log.Info("Found go.sum. version mismatch")
setCurrentRepo(repo, "VERY BROKEN", "rewind go.mod commit")
return
@ -239,9 +238,9 @@ func globalDisplayOptions(box *gui.Node) {
}
func hidePerfect() {
for _, repo := range me.allrepos {
if repo.dirtyLabel.String() == "PERFECT" {
if repo.hidden {
for _, repo := range me.repos.View.AllRepos() {
if repo.State() == "PERFECT" {
if repo.Hidden() {
continue
}
repo.Hide()

66
initRepoList.go Normal file
View File

@ -0,0 +1,66 @@
package main
// this initializes the repos
import (
"io/ioutil"
"os"
"os/user"
"path/filepath"
"strings"
"go.wit.com/lib/gui/repolist"
"go.wit.com/lib/gui/repostatus"
"go.wit.com/log"
)
func (r *repoWindow) initRepoList() {
usr, _ := user.Current()
repos := parsecfg("~/.config/guireleaser")
for _, line := range repos {
log.Verbose("repo =", line)
path, mbranch, dbranch, ubranch := splitLine(line)
if mbranch == "" {
mbranch = "master"
}
if dbranch == "" {
dbranch = "devel"
}
if ubranch == "" {
ubranch = usr.Username
}
r.View.AddRepo(path, mbranch, dbranch, ubranch)
}
log.Info("scanning everything in ~/go/src")
for i, path := range repostatus.ListGitDirectories() {
// log.Info("addRepo()", i, path)
path = strings.TrimPrefix(path, me.goSrcPwd.String())
path = strings.Trim(path, "/")
log.Info("addRepo()", i, path)
r.View.AddRepo(path, "master", "devel", usr.Username)
}
}
func parsecfg(f string) []string {
homeDir, _ := os.UserHomeDir()
cfgfile := filepath.Join(homeDir, f)
content, _ := ioutil.ReadFile(cfgfile)
out := string(content)
out = strings.TrimSpace(out)
lines := strings.Split(out, "\n")
return lines
}
// returns path, master branch name, devel branch name, user branch name
func splitLine(line string) (string, string, string, string) {
var path, master, devel, user string
parts := strings.Split(line, " ")
path, parts = repolist.RemoveFirstElement(parts)
master, parts = repolist.RemoveFirstElement(parts)
devel, parts = repolist.RemoveFirstElement(parts)
user, parts = repolist.RemoveFirstElement(parts)
// path, master, devel, user := strings.Split(line, " ")
return path, master, devel, user
}

View File

@ -4,54 +4,55 @@ package main
import (
"path/filepath"
"go.wit.com/lib/gui/repolist"
"go.wit.com/log"
)
func (r *repo) lookToUnwind() bool {
goSumS := r.getGoSumStatus()
dirtyS := r.dirtyLabel.String()
currentS := r.status.GetCurrentBranchVersion()
log.Info("repo:", r.String(), goSumS, dirtyS, r.lastTag.String(), currentS)
func lookToUnwind(r *repolist.Repo) bool {
goSumS := r.Status.GetGoSumStatus()
dirtyS := r.State()
currentS := r.Status.GetCurrentBranchVersion()
log.Info("repo:", r.Name(), goSumS, dirtyS, r.State(), currentS)
curName := r.status.GetCurrentBranchName()
mName := r.status.GetMasterBranchName()
curName := r.Status.GetCurrentBranchName()
mName := r.Status.GetMasterBranchName()
if curName == mName {
log.Info("\trepo is ready working from main branch", curName, "=", mName)
} else {
log.Info("\trepo is not ready main branch", curName, "!=", mName)
r.setGoSumStatus("CAN NOT UNWIND")
r.Status.SetGoSumStatus("CAN NOT UNWIND")
return false
}
if r.lastTag.String() != currentS {
log.Info("\trepo version mismatch last vs current", r.lastTag.String(), "!=", currentS)
r.setGoSumStatus("CAN NOT UNWIND")
if r.LastTag() != currentS {
log.Info("\trepo version mismatch last vs current", r.LastTag(), "!=", currentS)
r.Status.SetGoSumStatus("CAN NOT UNWIND")
return false
}
if release.version.String() != r.lastTag.String() {
log.Info("\trepo version mismatch last vs official", r.lastTag.String(), "!=", release.version.String())
r.setGoSumStatus("CAN NOT UNWIND")
if release.version.String() != r.LastTag() {
log.Info("\trepo version mismatch last vs official", r.LastTag(), "!=", release.version.String())
r.Status.SetGoSumStatus("CAN NOT UNWIND")
return false
}
fullpath := filepath.Join(me.goSrcPwd.String(), r.String())
fullpath := filepath.Join(me.goSrcPwd.String(), r.GoPath())
testf := filepath.Join(fullpath, "go.mod")
if Exists(testf) {
log.Info("\trepo is ready. go.mod exists")
r.setGoSumStatus("UNWIND")
r.Status.SetGoSumStatus("UNWIND")
return true
}
fullpath = filepath.Join(me.goSrcPwd.String(), r.String())
fullpath = filepath.Join(me.GoSrcPath(), r.GoPath())
testf = filepath.Join(fullpath, "go.sum")
if Exists(testf) {
log.Info("\trepo is ready. go.sum exists")
r.setGoSumStatus("UNWIND")
r.Status.SetGoSumStatus("UNWIND")
return true
}
r.setGoSumStatus("NO UNWIND?")
r.Status.SetGoSumStatus("NO UNWIND?")
return false
}

125
main.go
View File

@ -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()
})
}

View File

@ -10,12 +10,13 @@ import (
"go.wit.com/log"
"go.wit.com/lib/gadgets"
"go.wit.com/lib/gui/repolist"
)
var release releaseStruct
type releaseStruct struct {
current *repo
current *repolist.Repo
box *gui.Node
group *gui.Node
@ -40,11 +41,11 @@ type releaseStruct struct {
makeRedomodB *gui.Node
sendVersionB *gui.Node
checkSafeB *gui.Node
whitelist map[string]*repo
whitelist map[string]*repolist.Repo
// store myself here. use myself to
// do garbage go get tests and other potential junk
guireleaser *repo
guireleaser *repolist.Repo
}
func (w *autoType) Disable() {
@ -75,16 +76,18 @@ func createReleaseBox(box *gui.Node) {
me.Enable()
})
release.grid.NewButton("findNextDirty()", func() {
me.Disable()
defer me.Enable()
if findNextDirty("PRIMATIVE") {
log.Info("findNextDirty() found a repo")
return
}
if findNextDirty("") {
log.Info("findNextDirty() found a repo")
return
}
/*
me.Disable()
defer me.Enable()
if findNextDirty("PRIMATIVE") {
log.Info("findNextDirty() found a repo")
return
}
if findNextDirty("") {
log.Info("findNextDirty() found a repo")
return
}
*/
})
release.releaseVersionB = release.grid.NewButton("release version", func() {
@ -98,7 +101,7 @@ func createReleaseBox(box *gui.Node) {
})
release.openrepo = release.grid.NewButton("open repo", func() {
release.current.status.Toggle()
release.current.Status.Toggle()
})
release.openrepo.Disable()
@ -134,22 +137,22 @@ func createReleaseBox(box *gui.Node) {
release.grid.NewButton("Check Ready", func() {
buttonDisable()
defer buttonEnable()
goSumS := release.current.getGoSumStatus()
dirtyS := release.current.dirtyLabel.String()
lastS := release.current.status.GetLastTagVersion()
goSumS := release.current.GoState()
dirtyS := release.current.State()
lastS := release.current.LastTag()
if CheckReady() {
log.Info("repo is ready", release.current.String(), goSumS, dirtyS, lastS)
log.Info("repo is ready", release.current.Name(), goSumS, dirtyS, lastS)
return
} else {
log.Info("\trepo is not ready", release.current.String(), goSumS, dirtyS, lastS)
log.Info("\trepo is not ready", release.current.Name(), goSumS, dirtyS, lastS)
}
})
release.grid.NewButton("set ignore", func() {
tmp := release.current.getGoSumStatus()
tmp := release.current.GoState()
log.Info("trying to set repo IGNORE is now =", tmp)
release.current.setGoSumStatus("IGNORE")
release.whitelist[release.current.String()] = release.current
release.current.SetGoState("IGNORE")
release.whitelist[release.current.GoPath()] = release.current
})
release.checkSafeB = release.grid.NewButton("fullDoubleCheckFix()", func() {
@ -165,18 +168,18 @@ func createReleaseBox(box *gui.Node) {
release.checkGoSumB = release.grid.NewButton("CheckGoSum()", func() {
buttonDisable()
if ok, _ := release.current.status.CheckGoSum(); ok {
if ok, _ := release.current.Status.CheckGoSum(); ok {
log.Info("repo has go.sum requirements that are clean")
// release.current.setGoSumStatus("CLEAN")
release.status.SetValue("GOOD")
release.notes.SetValue("CheckGoSum() does not seem to lie")
release.status.SetText("GOOD")
release.notes.SetText("CheckGoSum() does not seem to lie")
}
buttonEnable()
})
release.makeRedomodB = release.grid.NewButton("make redomod", func() {
buttonDisable()
if release.current.status.MakeRedomod() {
if release.current.Status.MakeRedomod() {
} else {
log.Info("This is bad. stop here")
}
@ -198,8 +201,8 @@ func createReleaseBox(box *gui.Node) {
buttonDisable()
// rather than loop forever, at least limit this to the number of repos
// incase something, somewhere, goes wrong
duration := timeFunction(func() {
for n := 0; n <= len(me.allrepos); n++ {
duration := repolist.TimeFunction(func() {
for n := 0; n <= len(me.repos.View.AllRepos()); n++ {
if doRelease() {
log.Info("doRelease() worked")
} else {
@ -222,18 +225,18 @@ func createReleaseBox(box *gui.Node) {
}
func fullDoubleCheckFix() bool {
release.current.status.CheckSafeGoSumRemake()
if !release.current.status.MakeRedomod() {
release.current.Status.CheckSafeGoSumRemake()
if !release.current.Status.MakeRedomod() {
log.Info("go mod failed")
return false
}
if ok, _ := release.current.status.CheckGoSum(); ok {
if ok, _ := release.current.Status.CheckGoSum(); ok {
log.Info("go.sum is clean")
} else {
log.Info("repo go.sum FAILED")
return false
}
if ok, _ := release.current.status.CheckGoSum(); ok {
if ok, _ := release.current.Status.CheckGoSum(); ok {
log.Info("repo has go.sum requirements that are clean")
// release.current.setGoSumStatus("CLEAN")
release.status.SetValue("GOOD")
@ -244,43 +247,43 @@ func fullDoubleCheckFix() bool {
}
func goodCheckGoSum() bool {
tmp := release.current.String()
log.Info("goodCheckGoSum() START on repo:", tmp, "STATUS =", release.current.getGoSumStatus())
tmp := release.current.Name()
log.Info("goodCheckGoSum() START on repo:", tmp, "STATUS =", release.current.GoState())
var maybe bool = true
goConfig := release.current.status.GetGoDeps()
goConfig := release.current.Status.GetGoDeps()
for depname, version := range goConfig {
log.Info("Checking repo deps:", depname, version)
repo, ok := me.allrepos[depname]
if ok {
goSumS := repo.getGoSumStatus()
// ignore dependencies on whitelisted repos
// TODO: warn the user about the whitelist
if goSumS == "WHITELIST" {
continue
}
// check if the dependent repo is ReadOnly
// if so, there isn't anything we can do about
// version mis-matches
if repo.status.ReadOnly() {
continue
}
lastS := repo.status.GetLastTagVersion()
targetS := repo.targetVersion.String()
log.Info(" repo deps:", depname, version, "vs", goSumS, lastS, targetS)
if lastS != targetS {
log.Info("repo deps: FALSE lastS != targetS", lastS, targetS)
log.Info("repo deps: FALSE status.ReadOnly()", release.current.status.ReadOnly())
log.Info("repo deps: FALSE path", release.current.String())
maybe = false
}
} else {
repo := me.repos.View.FindRepo(depname)
if repo != nil {
log.Info(" repo deps: IGNORE", depname, version)
continue
}
goSumS := repo.GoState()
// ignore dependencies on whitelisted repos
// TODO: warn the user about the whitelist
if goSumS == "WHITELIST" {
continue
}
// check if the dependent repo is ReadOnly
// if so, there isn't anything we can do about
// version mis-matches
if repo.ReadOnly() {
continue
}
lastS := repo.LastTag()
targetS := repo.Status.GetTargetVersion()
log.Info(" repo deps:", depname, version, "vs", goSumS, lastS, targetS)
if lastS != targetS {
log.Info("repo deps: FALSE lastS != targetS", lastS, targetS)
log.Info("repo deps: FALSE status.ReadOnly()", release.current.ReadOnly())
log.Info("repo deps: FALSE path", release.current.GoPath())
maybe = false
}
}
if maybe {
log.Info("SUCCEEDED.", release.current.String())
log.Info("SUCCEEDED. goSumStatus.String() =", release.current.goSumStatus.String())
log.Info("SUCCEEDED.", release.current.Name())
log.Info("SUCCEEDED. goSumStatus.String() =", release.current.GoState())
log.Info("SUCCEEDED. MAYBE. try it again get go.sum requirements")
return true
} else {
@ -297,17 +300,17 @@ func buttonEnable() {
me.Enable()
}
func setCurrentRepo(newcur *repo, s string, note string) bool {
if newcur.status.ReadOnly() {
func setCurrentRepo(newcur *repolist.Repo, s string, note string) bool {
if newcur.ReadOnly() {
return false
}
release.repo.SetValue(newcur.status.String())
release.status.SetValue(s)
release.notes.SetValue(note)
release.repo.SetText(newcur.GoPath())
release.status.SetText(s)
release.notes.SetText(note)
release.current = newcur
release.version.SetText(release.current.targetVersion.String())
release.releaseVersionB.SetText("release version " + release.current.targetVersion.String())
release.version.SetText(release.current.Status.GetTargetVersion())
release.releaseVersionB.SetText("release version " + release.current.Status.GetTargetVersion())
// release.unreleaseB.SetText("un-release version " + release.current.targetVersion.String())
release.openrepo.Enable()
@ -315,14 +318,14 @@ func setCurrentRepo(newcur *repo, s string, note string) bool {
}
func scanForReady() bool {
for _, repo := range me.allrepos {
goSumS := repo.getGoSumStatus()
dirtyS := repo.dirtyLabel.String()
log.Info("findNextDirty()", repo.String(), goSumS, dirtyS)
for _, repo := range me.repos.View.AllRepos() {
goSumS := repo.GoState()
dirtyS := repo.State()
log.Info("findNextDirty()", repo.GoPath(), goSumS, dirtyS)
if whitelist(repo.String()) {
log.Info("found WHITELIST", repo.String())
repo.setGoSumStatus("WHITELIST")
if whitelist(repo.GoPath()) {
log.Info("found WHITELIST", repo.GoPath())
repo.Status.SetGoSumStatus("WHITELIST")
continue
}
@ -334,20 +337,21 @@ func scanForReady() bool {
return true
}
// trys to figure out if there is still something to update
// todo: redo this logic as it is terrible
func findNextDirty(onlyKind string) bool {
for key := range me.allrepos {
repo := me.allrepos[key]
goSumS := repo.getGoSumStatus()
dirtyS := repo.dirtyLabel.String()
for _, repo := range me.repos.View.AllRepos() {
goSumS := repo.Status.GetGoSumStatus()
// dirtyS := repo.State()
log.Info("findNextDirty()", repo.String(), goSumS, dirtyS)
if repo.status.ReadOnly() {
log.Info("findNextDirty()", repo.GoPath(), goSumS)
if repo.ReadOnly() {
log.Info("findNextDirty() skipping readonly")
continue
}
if goSumS == "PRIMATIVE" {
if setCurrentRepo(repo, "PRIMATIVE", "release new version") {
if release.version.String() == release.current.status.GetLastTagVersion() {
if release.version.String() == release.current.Status.GetLastTagVersion() {
// everything is fine. the primative has already been released
} else {
return true
@ -369,75 +373,15 @@ func findNextDirty(onlyKind string) bool {
continue
}
setCurrentRepo(repo, "REDO GOSUM", "try redoing the gosum")
newgoSumS := release.current.getGoSumStatus()
newdirtyS := release.current.dirtyLabel.String()
newlastS := release.current.status.GetLastTagVersion()
newgoSumS := release.current.GoState()
// newdirtyS := release.current.dirtyLabel.String()
newlastS := release.current.LastTag()
if goodCheckGoSum() {
log.Info("findNextDirty() returning true from goodCheckGoSum()", newgoSumS, newgoSumS, newdirtyS, newlastS)
log.Info("findNextDirty() returning true from goodCheckGoSum()", newgoSumS, newgoSumS, newlastS)
return true
} else {
// continue
}
if repo.String() == "go.wit.com/log" {
log.Info("findNextDirty() FOUND LOG", repo.String(), goSumS, dirtyS)
log.Info("findNextDirty() FOUND LOG", repo.String(), goSumS, dirtyS)
log.Info("findNextDirty() FOUND LOG", repo.String(), goSumS, dirtyS)
log.Info("findNextDirty() FOUND LOG", repo.String(), goSumS, dirtyS)
log.Info("findNextDirty() FOUND LOG", repo.String(), goSumS, dirtyS)
log.Sleep(10)
return true
}
continue
if goSumS == "UNRELEASED" {
if setCurrentRepo(repo, "UNRELEASED", "manually check go.sum") {
return true
}
continue
}
if goSumS == "NOT READY" {
if setCurrentRepo(repo, "NOT READY", "manually check go.sum") {
return true
}
continue
}
if goSumS == "DIRTY 2" {
continue
}
if goSumS == "BAD DEP" {
// find out what kind of BAD DEP?
continue
}
// latestversion := repo.status.GetLastTagVersion()
if goSumS == "CLEAN" {
// if it's clean here, then check and remake the go.sum file
// then stop to commit the release version
repo.checkSafeGoSumRemake()
if repo.checkDirty() {
dirtyS = repo.dirtyLabel.String()
}
if dirtyS == "PERFECT" {
continue
}
if setCurrentRepo(repo, "clean", "check manually") {
return true
}
}
if goSumS == "DIRTY" {
if ok, missing := repo.status.CheckGoSum(); ok {
log.Info("repo has go.sum requirements that are clean")
// repo.setGoSumStatus("CLEAN")
} else {
log.Info("DIRTY 2 repo has go.sum requirements that are screwed up. missing:", missing)
repo.setGoSumStatus("DIRTY 2")
continue
}
if setCurrentRepo(repo, "dirty", "commit changes") {
return true
}
}
}
log.Info("tried to findNextDirty() but not sure what to do next")
release.status.SetValue("ALL DONE?")
release.status.SetText("ALL DONE?")
return false
}

View File

@ -1,167 +0,0 @@
// This is a simple example
package main
import (
"io/ioutil"
"os/user"
"strings"
"go.wit.com/gui"
"go.wit.com/lib/gadgets"
"go.wit.com/lib/gui/repostatus"
"go.wit.com/log"
)
func (r *repo) String() string {
if r.status == nil {
return r.path
}
return r.status.String()
}
func (r *repo) getPath() string {
return r.path
}
func RemoveFirstElement(slice []string) (string, []string) {
if len(slice) == 0 {
return "", slice // Return the original slice if it's empty
}
return slice[0], slice[1:] // Return the slice without the first element
}
// returns path, master branch name, devel branch name, user branch name
func splitLine(line string) (string, string, string, string) {
var path, master, devel, user string
parts := strings.Split(line, " ")
path, parts = RemoveFirstElement(parts)
master, parts = RemoveFirstElement(parts)
devel, parts = RemoveFirstElement(parts)
user, parts = RemoveFirstElement(parts)
// path, master, devel, user := strings.Split(line, " ")
return path, master, devel, user
}
func myrepolist() []string {
content, _ := ioutil.ReadFile("/home/jcarr/.config/myrepolist")
out := string(content)
out = strings.TrimSpace(out)
lines := strings.Split(out, "\n")
return lines
}
func (r *repo) Hide() {
r.pLabel.Hide()
r.lastTag.Hide()
r.vLabel.Hide()
r.targetVersion.Hide()
r.dirtyLabel.Hide()
r.goSumStatus.Hide()
r.statusButton.Hide()
r.hidden = true
}
func (r *repo) Show() {
r.pLabel.Show()
r.lastTag.Show()
r.vLabel.Show()
r.targetVersion.Show()
r.dirtyLabel.Show()
r.goSumStatus.Show()
r.statusButton.Show()
r.hidden = false
}
// This creates a window
func repoworld() {
reposwin = gadgets.NewBasicWindow(me.myGui, "All git repositories in ~/go/src/")
reposwin.Make()
reposwin.Custom = func() {
log.Warn("GOT HERE: main() gadgets.NewBasicWindow() close")
log.Warn("Should I do something special here?")
}
reposbox = reposwin.Box().NewBox("bw vbox", false)
reposgroup = reposbox.NewGroup("go repositories (read from ~/.config/myrepolist)")
reposgrid = reposgroup.NewGrid("test", 7, 1)
reposgrid.NewLabel("") // path goes here
reposgrid.NewLabel("last tag")
reposgrid.NewLabel("Current Ver")
reposgrid.NewLabel("Target Ver")
reposgrid.NewLabel("Status")
reposgrid.NewLabel("go.sum")
reposgrid.NewLabel("Show()")
repos := myrepolist()
for _, line := range repos {
log.Verbose("repo =", line)
path, mbranch, dbranch, ubranch := splitLine(line)
if mbranch == "" {
mbranch = "master"
}
if dbranch == "" {
dbranch = "devel"
}
usr, _ := user.Current()
if ubranch == "" {
ubranch = usr.Username
}
addRepo(reposgrid, path, mbranch, dbranch, ubranch)
}
for i, path := range repostatus.ListGitDirectories() {
// log.Info("addRepo()", i, path)
tmp := strings.TrimPrefix(path, "/home/jcarr/go/src/")
log.Info("addRepo()", i, tmp)
addRepo(reposgrid, tmp, "master", "master", "master")
}
}
func addRepo(grid *gui.Node, path string, master string, devel string, user string) {
_, ok := me.allrepos[path]
if ok {
log.Info("addRepo() already had path", path)
return
}
newRepo := new(repo)
if path == "" {
log.Warn("addRepo() got empty path", path, master, devel, user)
return
}
newRepo.path = path
newRepo.pLabel = grid.NewLabel(path)
newRepo.lastTag = grid.NewLabel("")
newRepo.vLabel = grid.NewLabel("")
newRepo.targetVersion = grid.NewLabel("")
newRepo.dirtyLabel = grid.NewLabel("")
newRepo.goSumStatus = grid.NewLabel("?")
newRepo.statusButton = grid.NewButton("Configure", func() {
if newRepo.status == nil {
log.Warn("status window doesn't exist")
return
}
log.Warn("status window exists. trying TestDraw() here")
newRepo.status.Toggle()
setCurrentRepo(newRepo, "manually chosen", "notsure")
})
newRepo.status = repostatus.NewRepoStatusWindow(newRepo.path)
if newRepo.status == nil {
log.Warn("something is wrong with", path)
os.Exit(0)
}
newRepo.hidden = false
me.allrepos[path] = newRepo
}

73
repoview.go Normal file
View File

@ -0,0 +1,73 @@
package main
import (
"go.wit.com/lib/gadgets"
"go.wit.com/lib/gui/repolist"
"go.wit.com/log"
"go.wit.com/gui"
)
type repoWindow struct {
win *gadgets.BasicWindow
box *gui.Node
View *repolist.RepoList
}
func (r *repoWindow) Hidden() bool {
return r.win.Hidden()
}
func (r *repoWindow) Show() {
r.win.Show()
}
func (r *repoWindow) Hide() {
r.win.Hide()
}
func (r *repoWindow) Disable() {
r.box.Disable()
}
func (r *repoWindow) Enable() {
r.box.Enable()
}
// you can only have one of these
func makeRepoView() *repoWindow {
if me.repos != nil {
return me.repos
}
r := new(repoWindow)
r.win = gadgets.RawBasicWindow("All git repositories in ~/go/src/")
r.win.Make()
r.box = r.win.Box().NewBox("bw vbox", false)
// me.reposwin.Draw()
r.win.Custom = func() {
log.Warn("GOT HERE: main() gadgets.NewBasicWindow() close")
log.Warn("Should I do something special here?")
}
r.repoAllButtons()
r.View = repolist.GuireleaserView(r.box)
return r
}
func (r *repoWindow) repoAllButtons() {
// reposbox.SetExpand(false)
group1 := r.box.NewGroup("Run on all repos:")
hbox := group1.Box()
// hbox.Horizontal()
hbox.Vertical()
box2 := hbox.Box().Vertical()
box2.NewButton("something", func() {
r.Disable()
r.Enable()
})
}

88
scan.go
View File

@ -1,88 +0,0 @@
package main
import (
"fmt"
"strings"
"time"
"go.wit.com/log"
)
func scanRepositories() {
var i int = 0
t := timeFunction(func() {
for _, repo := range me.allrepos {
repo.newScan()
i += 1
}
})
s := fmt.Sprint(t)
log.Info("Scanned", i, "repositories. todo: count/show changes", s)
}
func (r *repo) newScan() bool {
if r.status == nil {
log.Warn("repo.status = nil. not initialized for some reason")
return false
}
// first run the repostatus update
r.status.UpdateNew()
// now read those values and display them in our table
// mname := r.status.GetMasterBranchName()
// mver := r.status.GetMasterVersion()
// mver = mver + " (" + mname + ")"
// r.masterVersion.SetLabel(mver)
cbname := r.status.GetCurrentBranchName()
cbversion := r.status.GetCurrentBranchVersion()
lasttag := r.status.GetLastTagVersion()
r.lastTag.SetLabel(lasttag)
r.vLabel.SetLabel(cbname + " " + cbversion)
if c, ok := r.status.Changed(); ok {
c := strings.TrimSpace(c)
for _, line := range strings.Split(c, "\n") {
log.Info(r.status.Path(), line)
}
}
status := r.status.GetStatus()
r.dirtyLabel.SetLabel(status)
if status == "PERFECT" {
if me.autoHidePerfect.Checked() {
r.Hide()
}
return true
}
return false
}
// timeFunction takes a function as an argument and returns the execution time.
func timeFunction(f func()) time.Duration {
startTime := time.Now() // Record the start time
f() // Execute the function
return time.Since(startTime) // Calculate the elapsed time
}
func myTicker(t time.Duration, name string, f func()) {
ticker := time.NewTicker(t)
defer ticker.Stop()
done := make(chan bool)
/*
go func() {
time.Sleep(10 * time.Second)
done <- true
}()
*/
for {
select {
case <-done:
fmt.Println("Done!")
return
case t := <-ticker.C:
log.Verbose(name, "Current time: ", t)
f()
}
}
}

View File

@ -2,61 +2,55 @@
package main
import (
"go.wit.com/lib/gui/repolist"
"go.wit.com/log"
)
func (r *repo) getGoSumStatus() string {
return r.goSumStatus.String()
/*
func getGoSumStatus(r *repolist.Repo) string {
return r.Status.GoSumStatus.String()
}
func (r *repo) setGoSumStatus(s string) {
func setGoSumStatus(r *repolist.Repo, s string) {
r.goSumStatus.SetLabel(s)
r.status.SetGoSumStatus(s)
}
*/
func (r *repo) checkDirty() bool {
if r.status.CheckDirty() {
log.Info("dirty repo:", r.status.String(), r.getGoSumStatus())
r.setGoSumStatus("DIRTY")
return true
}
return false
}
func (r *repo) checkSafeGoSumRemake() {
if ok, bad := r.status.CheckSafeGoSumRemake(); ok {
func checkSafeGoSumRemake(r *repolist.Repo) {
if ok, bad := r.Status.CheckSafeGoSumRemake(); ok {
log.Info("checkSafeGoSumRemake() is safe to redo")
r.setGoSumStatus("SAFE")
r.status.MakeRedomod()
r.Status.SetGoSumStatus("SAFE")
r.Status.MakeRedomod()
} else {
log.Info("checkSafeGoSumRemake() is not safe. problems:", bad)
r.setGoSumStatus("BAD DEP")
r.Status.SetGoSumStatus("BAD DEP")
}
}
func scanGoSum() {
for _, repo := range me.allrepos {
if repo.String() == "go.wit.com/apps/guireleaser" {
for _, repo := range me.repos.View.AllRepos() {
if repo.GoPath() == "go.wit.com/apps/guireleaser" {
if release.guireleaser == nil {
release.guireleaser = repo
}
}
latestversion := repo.status.GetLastTagVersion()
if repo.getGoSumStatus() == "BAD" {
latestversion := repo.Status.GetLastTagVersion()
if repo.GoState() == "BAD" {
continue
}
if repo.getGoSumStatus() == "DIRTY" {
if repo.GoState() == "DIRTY" {
continue
}
if repo.status.CheckPrimativeGoMod() {
log.Info("PRIMATIVE repo:", latestversion, repo.status.String())
repo.setGoSumStatus("PRIMATIVE")
if repo.Status.CheckPrimativeGoMod() {
log.Info("PRIMATIVE repo:", latestversion, repo.GoPath())
repo.SetGoState("PRIMATIVE")
continue
}
if repo.checkDirty() {
log.Info("dirty repo:", latestversion, repo.status.String())
log.Info("dirty repo.getGoSumStatus =", repo.getGoSumStatus())
repo.setGoSumStatus("DIRTY")
if repo.CheckDirty() {
log.Info("dirty repo:", latestversion, repo.GoPath())
log.Info("dirty repo.getGoSumStatus =", repo.GoState())
repo.SetGoState("DIRTY")
// release.repo.SetValue(repo.status.String())
// release.status.SetValue("dirty")
@ -65,12 +59,12 @@ func scanGoSum() {
// release.openrepo.Enable()
continue
}
if ok, missing := repo.status.CheckGoSum(); ok {
if ok, missing := repo.Status.CheckGoSum(); ok {
log.Info("repo has go.sum requirements that are clean")
repo.setGoSumStatus("CLEAN")
repo.SetGoState("CLEAN")
} else {
log.Info("repo has go.sum requirements that are screwed up. missing:", missing)
repo.setGoSumStatus("BAD")
repo.SetGoState("BAD")
// release.repo.SetValue(repo.status.String())
// release.status.SetValue("bad")
@ -79,14 +73,14 @@ func scanGoSum() {
// release.openrepo.Enable()
continue
}
status := repo.dirtyLabel.String()
status := repo.State()
if status == "PERFECT" {
continue
} else {
repo.newScan()
repo.NewScan()
}
log.Info("repo:", latestversion, status, repo.status.String())
log.Info("repo:", latestversion, status, repo.GoPath())
}
log.Info("scanGoSum() did everything, not sure what to do next")
}

View File

@ -4,11 +4,10 @@ package main
import (
"go.wit.com/gui"
"go.wit.com/lib/gadgets"
"go.wit.com/lib/gui/repostatus"
)
// the main window nodes
var reposwin *gadgets.BasicWindow
// var reposwin *gadgets.BasicWindow
var reposbox *gui.Node
var reposgrid *gui.Node
var reposgroup *gui.Node
@ -16,15 +15,17 @@ var reposgroup *gui.Node
var me *autoType
type autoType struct {
allrepos map[string]*repo
myGui *gui.Node
myGui *gui.Node
releaseReasonS string // = "gocui dropdown select"
// autotypistWindow *gadgets.BasicWindow
// guireleaser window
mainWindow *gui.Node
mainBox *gui.Node
// our view of the repositories
repos *repoWindow
// #### autotypist Global Display Options
autoHidePerfect *gui.Node
autoHideReadOnly *gui.Node
@ -77,12 +78,17 @@ type autoType struct {
setBranchesToMasterB *gui.Node
}
func (my *autoType) GoSrcPath() string {
return my.goSrcPwd.String()
}
/*
var cmds *gui.Node
var doit *gui.Node
var dryrun *gui.Node
*/
/*
type repo struct {
hidden bool
path string
@ -104,3 +110,4 @@ type repo struct {
status *repostatus.RepoStatus
}
*/

View File

@ -3,13 +3,15 @@ package main
import (
"strings"
"go.wit.com/lib/gui/repolist"
)
func initWhitelist() {
release.whitelist = make(map[string]*repo)
for _, repo := range me.allrepos {
if strings.HasPrefix(repo.String(), "go.wit.com/dev/davecgh") {
release.whitelist[repo.String()] = repo
release.whitelist = make(map[string]*repolist.Repo)
for _, repo := range me.repos.View.AllRepos() {
if strings.HasPrefix(repo.GoPath(), "go.wit.com/dev/davecgh") {
release.whitelist[repo.GoPath()] = repo
}
// if repo.String() == "go.wit.com/apps/guireleaser" {
// release.whitelist[repo.String()] = repo