From 41a61668908536a860dc78de0c9eedbfc179dd63 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Thu, 1 Feb 2024 13:30:26 -0600 Subject: [PATCH] add version number exception for widget Signed-off-by: Jeff Carr --- checkReady.go | 5 ++- globalDisplayOptions.go | 9 +++- lookForUnwind.go | 4 +- releaseWindow.go | 92 ++++++++++++++++++++++------------------- unreleaseWindow.go | 26 ++++++++---- 5 files changed, 82 insertions(+), 54 deletions(-) diff --git a/checkReady.go b/checkReady.go index 2a9fad2..2a5c2e3 100644 --- a/checkReady.go +++ b/checkReady.go @@ -35,8 +35,9 @@ func CheckReady() bool { lastS := release.current.status.GetLastTagVersion() currentS := release.current.status.GetCurrentBranchVersion() - targetS := "v" + release.versionS - log.Info("repo:", release.current.String(), goSumS, dirtyS, lastS, currentS) + var targetS string + targetS = "v" + release.version.String() + log.Info("repo:", release.current.String(), goSumS, dirtyS, lastS, currentS, targetS) if goSumS == "PRIMATIVE" { return true diff --git a/globalDisplayOptions.go b/globalDisplayOptions.go index e0506a1..c561521 100644 --- a/globalDisplayOptions.go +++ b/globalDisplayOptions.go @@ -100,8 +100,15 @@ func globalDisplayOptions(box *gui.Node) { if whitelist(repo.String()) { continue } - repo.status.MakeRedomod() + if repo.status.MakeRedomod() { + log.Info("redo go.sum failed on", repo.String()) + me.Enable() + longB.Enable() + longB.SetLabel("FAILED") + return + } } + log.Info("redo go.sum finished ok!") me.Enable() longB.Enable() }) diff --git a/lookForUnwind.go b/lookForUnwind.go index 5c101bb..1ca7954 100644 --- a/lookForUnwind.go +++ b/lookForUnwind.go @@ -30,8 +30,8 @@ func (r *repo) lookToUnwind() bool { return false } - if "v"+release.versionS != r.lastTag.String() { - log.Info("\trepo version mismatch last vs official", r.lastTag.String(), "!=", release.versionS) + 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") return false } diff --git a/releaseWindow.go b/releaseWindow.go index 0fb62db..437cba0 100644 --- a/releaseWindow.go +++ b/releaseWindow.go @@ -17,18 +17,20 @@ var release releaseStruct type releaseStruct struct { current *repo - // win *gadgets.BasicWindow - box *gui.Node - group *gui.Node - grid *gui.Node - repo *gadgets.OneLiner - status *gadgets.OneLiner - readOnly *gadgets.OneLiner - notes *gadgets.OneLiner - version *gadgets.OneLiner - versionS string - reason *gadgets.BasicEntry - reasonS string + box *gui.Node + group *gui.Node + grid *gui.Node + repo *gadgets.OneLiner + status *gadgets.OneLiner + readOnly *gadgets.OneLiner + notes *gadgets.OneLiner + version *gadgets.OneLiner + versionS string + widgetVersionS string + releaseVersionB *gui.Node + unreleaseB *gui.Node + reason *gadgets.BasicEntry + reasonS string openrepo *gui.Node @@ -54,9 +56,9 @@ func (w *autoType) Enable() { } func createReleaseBox(box *gui.Node) { - release.versionS = "0.18.0" - release.reasonS = "dns control panel" - partS := strings.Split(release.versionS, ".") + release.versionS = "0.19.0" + release.widgetVersionS = "1.1.13" + release.reasonS = "gocui checkboxes" initWhitelist() @@ -81,8 +83,22 @@ func createReleaseBox(box *gui.Node) { } me.Enable() }) - release.grid.NewButton("release version "+release.versionS, func() { + release.releaseVersionB = release.grid.NewButton("release version", func() { buttonDisable() + if release.releaseVersionB.String() != "release version "+release.version.String() { + log.Warn("something went wrong with the release.version:", release.version.String()) + return + } + if strings.HasPrefix(release.version.String(), "v") { + log.Warn("everything is ok. version starts with v.", release.version.String()) + } else { + log.Warn("version does not start with v.", release.version.String()) + return + } + if release.status.String() != "PRIMATIVE" { + log.Warn("only can do PRIMATIVE right now", release.version.String()) + return + } if release.current.status.CheckDirty() { log.Info("sorry, it's still dirty") @@ -96,15 +112,19 @@ func createReleaseBox(box *gui.Node) { return } - log.Info("\ttag and push", curName, release.versionS, release.reasonS) + log.Info("\ttag and push", curName, release.version.String(), release.reasonS) var all [][]string all = append(all, []string{"git", "add", "-f", "go.mod"}) - all = append(all, []string{"git", "add", "-f", "go.sum"}) + if release.status.String() == "PRIMATIVE" { + // don't add go.sum here. TODO: check for go.sum file and fail + } else { + all = append(all, []string{"git", "add", "-f", "go.sum"}) + } all = append(all, []string{"git", "commit", "-m", release.reasonS}) all = append(all, []string{"git", "push"}) - all = append(all, []string{"git", "tag", "-m", release.reasonS, "v" + release.versionS}) - all = append(all, []string{"git", "push", "origin", "v" + release.versionS}) + all = append(all, []string{"git", "tag", "-m", release.reasonS, release.version.String()}) + all = append(all, []string{"git", "push", "origin", release.version.String()}) if doAll(release.current, all) { log.Info("EVERYTHING OK") @@ -149,7 +169,6 @@ func createReleaseBox(box *gui.Node) { // open the status window to commit the release release.current.status.Toggle() - release.current.status.SetVersion(partS[0], partS[1], partS[2], release.reason.String()) release.current.status.UpdateCurrent() }) release.openrepo.Disable() @@ -160,7 +179,6 @@ func createReleaseBox(box *gui.Node) { release.notes = gadgets.NewOneLiner(release.grid, "notes") release.version = gadgets.NewOneLiner(release.grid, "version") - release.version.SetText(release.versionS) release.reason = gadgets.NewBasicEntry(release.grid, "release reason") release.reason.SetText(release.reasonS) @@ -192,13 +210,6 @@ func createReleaseBox(box *gui.Node) { } }) - /* - release.sendVersionB = release.grid.NewButton("send version", func() { - log.Info("set version()") - release.current.status.SetVersion(partS[0], partS[1], partS[2], release.reason.String()) - }) - */ - release.grid.NewButton("set ignore", func() { tmp := release.current.getGoSumStatus() log.Info("trying to set repo IGNORE is now =", tmp) @@ -206,18 +217,6 @@ func createReleaseBox(box *gui.Node) { release.whitelist[release.current.String()] = release.current }) - /* - release.checkDirtyB = release.grid.NewButton("checkDirty()", func() { - buttonDisable() - if release.current.checkDirty() { - log.Info("repo is dirty") - } else { - log.Info("repo is not dirty") - } - buttonEnable() - }) - */ - release.checkSafeB = release.grid.NewButton("CheckSafeGoSumRemake()", func() { buttonDisable() release.current.status.CheckSafeGoSumRemake() @@ -351,6 +350,15 @@ func setCurrentRepo(newcur *repo, s string, note string) bool { release.status.SetValue(s) release.notes.SetValue(note) release.current = newcur + if newcur.String() == "go.wit.com/widget" { + release.version.SetText("v" + release.widgetVersionS) + release.releaseVersionB.SetText("release version v" + release.widgetVersionS) + release.unreleaseB.SetText("un-release version v" + release.widgetVersionS) + } else { + release.version.SetText("v" + release.versionS) + release.releaseVersionB.SetText("release version v" + release.versionS) + release.unreleaseB.SetText("un-release version v" + release.versionS) + } release.openrepo.Enable() /* @@ -390,7 +398,7 @@ func findNextDirty() bool { log.Info("findNextDirty()", repo.String(), goSumS, dirtyS) if goSumS == "PRIMATIVE" { if dirtyS != "PERFECT" { - if setCurrentRepo(repo, "primative not committed", "release new version") { + if setCurrentRepo(repo, "PRIMATIVE", "release new version") { return true } continue diff --git a/unreleaseWindow.go b/unreleaseWindow.go index a21062a..228860b 100644 --- a/unreleaseWindow.go +++ b/unreleaseWindow.go @@ -2,6 +2,8 @@ package main import ( + "strings" + "go.wit.com/gui" "go.wit.com/log" ) @@ -26,8 +28,19 @@ func createUnreleaseBox(box *gui.Node) { } } }) - group.NewButton("re-release"+release.versionS, func() { + release.unreleaseB = group.NewButton("re-release", func() { me.Disable() + if release.releaseVersionB.String() != "un-release version "+release.version.String() { + log.Warn("something went wrong with the release.version:", release.version.String()) + return + } + + if strings.HasPrefix(release.version.String(), "v") { + log.Warn("everything is ok. version starts with v.", release.version.String()) + } else { + log.Warn("version does not start with v.", release.version.String()) + return + } if release.current.status.CheckDirty() { log.Info("sorry, it's still dirty") @@ -41,8 +54,7 @@ func createUnreleaseBox(box *gui.Node) { return } - log.Info("\treset to devel", curName, release.versionS, release.reasonS) - + log.Info("\treset to devel", curName, release.version.String(), release.reasonS) var all [][]string all = append(all, []string{"git", "checkout", "devel"}) @@ -51,10 +63,10 @@ func createUnreleaseBox(box *gui.Node) { all = append(all, []string{"git", "checkout", mName}) all = append(all, []string{"git", "push", "--set-upstream", "--force", "origin", mName}) - all = append(all, []string{"git", "tag", "--delete", "v" + release.versionS}) - all = append(all, []string{"git", "push", "--delete", "origin", "v" + release.versionS}) - all = append(all, []string{"git", "tag", "-m", release.reasonS, "v" + release.versionS}) - all = append(all, []string{"git", "push", "origin", "v" + release.versionS}) + all = append(all, []string{"git", "tag", "--delete", release.version.String()}) + all = append(all, []string{"git", "push", "--delete", "origin", release.version.String()}) + all = append(all, []string{"git", "tag", "-m", release.reasonS, release.version.String()}) + all = append(all, []string{"git", "push", "origin", release.version.String()}) if doAll(release.current, all) { log.Info("EVERYTHING OK")