summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-12-02 05:13:17 -0600
committerJeff Carr <[email protected]>2024-12-02 05:13:17 -0600
commitcfb4fb61bfab6e6816c0080b47d6a6d4b935cea2 (patch)
tree91be3748e0fb1c09cd0fa169d78ef65fc657fcb8
parent02f7ee387ff083d5c39b3d99ec9defe3e66e3700 (diff)
more rewriting of old code
-rw-r--r--Makefile13
-rw-r--r--doRelease.go30
-rw-r--r--findNext.go77
-rw-r--r--globalDisplayOptions.go92
-rw-r--r--http.go19
-rw-r--r--main.go3
-rw-r--r--releaseBox.go7
7 files changed, 151 insertions, 90 deletions
diff --git a/Makefile b/Makefile
index 64881b9..89f836a 100644
--- a/Makefile
+++ b/Makefile
@@ -25,9 +25,6 @@ install:
GO111MODULE=off go install \
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
-test: build
- GUIRELEASE_REASON='test build' ./guireleaser
-
check-git-clean:
@git diff-index --quiet HEAD -- || (echo "Git repository is dirty, please commit your changes first"; exit 1)
@@ -40,9 +37,6 @@ redomod:
curl-help:
curl --silent http://localhost:9419/help
-tempWin:
- curl --silent http://localhost:9419/tempWin
-
curl-rescan-All:
curl --silent http://localhost:9419/rescanAll
@@ -60,6 +54,9 @@ findNext:
showNext:
curl --silent http://localhost:9419/showNext
+testNext:
+ curl --silent http://localhost:9419/testNext
+
doRelease:
reset
make curl-list-changed
@@ -70,6 +67,10 @@ doRelease:
curl-setCurrent-go-wit-com-gui:
curl --silent http://localhost:9419/setCurrentRepo?repo=go.wit.com/gui
+curl-setCurrent-go-clone:
+ curl --silent http://localhost:9419/setCurrentRepo?repo=go.wit.com/apps/go-clone
+ make showNext
+
curl-setTargetVersion-virtigo-v0.1.1:
curl --silent http://localhost:9419/setTargetVersion?version=v0.1.1
diff --git a/doRelease.go b/doRelease.go
index a3c5ec8..e350db3 100644
--- a/doRelease.go
+++ b/doRelease.go
@@ -29,11 +29,15 @@ func doRelease() bool {
if shell.Exists("go.mod") {
log.Info("go.mod exists ok")
} else {
- pwd, _ := os.Getwd()
- log.Info("go.mod disappeared. need to run go mod init and go mod tidy here:", pwd)
- shell.RunRealtime([]string{"go", "mod", "init"})
- shell.RunRealtime([]string{"go", "mod", "tidy"})
- shell.RunRealtime([]string{"go", "mod", "edit", "-go=1.20"})
+ log.Info("go.mod missing")
+ return false
+ /*
+ pwd, _ := os.Getwd()
+ log.Info("go.mod disappeared. need to run go mod init and go mod tidy here:", pwd)
+ shell.RunRealtime([]string{"go", "mod", "init"})
+ shell.RunRealtime([]string{"go", "mod", "tidy"})
+ shell.RunRealtime([]string{"go", "mod", "edit", "-go=1.20"})
+ */
}
curName := me.current.Status.GetCurrentBranchName()
@@ -43,7 +47,12 @@ func doRelease() bool {
return false
}
- if !checkValidGoSum(me.current) {
+ check := me.forge.Repos.FindByGoPath(me.current.GoPath())
+ if check == nil {
+ log.Info("boo, you didn't git clone", me.current.GoPath())
+ return false
+ }
+ if !me.forge.FinalGoDepsCheck(check) {
return false
}
@@ -116,7 +125,7 @@ func doRelease() bool {
me.current.NewScan()
pb := me.forge.Repos.FindByGoPath(me.current.GoPath())
if pb != nil {
- pb.RedoGoMod()
+ pb.ParseGoSum()
if pb.Published != nil {
loop := pb.Published.SortByGoPath()
for loop.Scan() {
@@ -153,7 +162,12 @@ func doReleaseFindNext() bool {
log.Info("findNext() could not find anything")
return false
}
- if checkValidGoSum(me.current) {
+ check := me.forge.Repos.FindByGoPath(me.current.GoPath())
+ if check == nil {
+ log.Info("boo, you didn't git clone", me.current.GoPath())
+ return false
+ }
+ if me.forge.FinalGoDepsCheck(check) {
return true
}
return false
diff --git a/findNext.go b/findNext.go
index b6a3867..9ffb6b7 100644
--- a/findNext.go
+++ b/findNext.go
@@ -41,10 +41,12 @@ func findNext() bool {
continue
}
log.Info("findNext()", repo.GoPath(), "is not a primative repo")
- if ! goodGodeps(repo) {
- continue
+ check := me.forge.Repos.FindByGoPath(repo.GoPath())
+ if check == nil {
+ log.Info("boo, you didn't git clone", repo.GoPath())
+ return false
}
- if checkValidGoSum(repo) {
+ if me.forge.FinalGoDepsCheck(check) {
setCurrentRepo(repo, "should be good to release", "pretty sure")
return true
}
@@ -54,22 +56,20 @@ func findNext() bool {
return false
}
+/*
func checkValidGoSum(repo *repolist.RepoRow) bool {
- ok, err := me.repos.View.CheckValidGoSum(repo)
- if err != nil {
- log.Info("go mod tidy not ok", err)
- return false
- }
- if ok {
+ if goodGodeps(repo) {
log.Info("repo has go.sum requirements that are clean")
// me.current.setGoSumStatus("CLEAN")
me.release.status.SetValue("GOOD")
me.release.notes.SetValue("CheckValidGoSum() does not seem to lie")
return true
}
+ log.Info("go mod tidy not ok")
me.release.notes.SetValue("CheckValidGoSum() failed")
return false
}
+*/
func goodGodeps(repo *repolist.RepoRow) bool {
var good bool = true
@@ -79,7 +79,7 @@ func goodGodeps(repo *repolist.RepoRow) bool {
log.Info("boo, you didn't git clone", repo.GoPath())
os.Exit(-1)
}
- check.RedoGoMod()
+ // check.RedoGoMod()
log.Printf("current repo %s go dependancy count: %d", check.GetGoPath(), check.GoDepsLen())
deps := check.GoDeps.SortByGoPath()
for deps.Scan() {
@@ -103,23 +103,54 @@ func goodGodeps(repo *repolist.RepoRow) bool {
log.Info("bad", header)
good = false
}
+ return good
+}
- /*
- log.Info(repolist.ReleaseReportHeader())
- loop := me.repos.View.ReposSortByName()
- for loop.Scan() {
- repo := loop.Repo()
-
- // if repo.ReadOnly() {
- // continue
- // }
- if repo.Status.IsReleased() {
+// tries to fix the go.mod and go.sum files
+func fixGodeps(repo *repolist.RepoRow) bool {
+ var good bool = true
+ // check if the package dependancies changed, if so, re-publish
+ check := me.forge.Repos.FindByGoPath(repo.GoPath())
+ if check == nil {
+ log.Info("boo, you didn't git clone", repo.GoPath())
+ os.Exit(-1)
+ }
+ check.RedoGoMod()
+ log.Printf("current repo %s go dependancy count: %d", check.GetGoPath(), check.GoDepsLen())
+ deps := check.GoDeps.SortByGoPath()
+ for deps.Scan() {
+ depRepo := deps.Next()
+ // log.Info("found dep", depRepo.GetGoPath())
+ if me.forge.IsReadOnly(depRepo.GetGoPath()) {
+ log.Info("IsReadOnly = true", depRepo.GetGoPath())
continue
+ } else {
+ // log.Info("IsReadOnly = false", depRepo.GetGoPath())
+ }
+ found := me.repos.View.FindByPath(depRepo.GetGoPath())
+ if found == nil {
+ log.Info("not found:", depRepo.GetGoPath())
+ continue
+ }
+ if depRepo.GetVersion() != found.Status.GetMasterVersion() {
+ log.Printf("%-48s %10s (from gitpb)", depRepo.GetGoPath(), depRepo.GetVersion())
+ header := found.StandardReleaseHeader()
+ log.Info(header, "(from repolist)")
+ cmd := []string{"go", "get", depRepo.GetGoPath() + "@latest"}
+ check.Run(cmd)
}
- header := repo.StandardReleaseHeader()
- log.Info(header)
}
- */
+ cmd := []string{"go", "mod", "tidy"}
+ check.Run(cmd)
+ cmd = []string{"go", "mod", "edit", "-go=1.20"}
+ check.Run(cmd)
+ check.GoDeps = nil
+ check.ParseGoSum()
+ deps = check.GoDeps.SortByGoPath()
+ for deps.Scan() {
+ depRepo := deps.Next()
+ log.Info("found updated dep", depRepo.GetGoPath(), depRepo.GetVersion())
+ }
return good
}
diff --git a/globalDisplayOptions.go b/globalDisplayOptions.go
index 3521e26..ed26177 100644
--- a/globalDisplayOptions.go
+++ b/globalDisplayOptions.go
@@ -30,50 +30,7 @@ func globalDisplayOptions(box *gui.Node) {
grid := group1.RawGrid()
grid.NewButton("make prepare-release", func() {
- me.Disable()
- me.release.box.Disable()
- defer me.Enable()
- loop := me.repos.View.ReposSortByName()
- for loop.Scan() {
- repo := loop.Repo()
- // check if the package dependancies changed, if so, re-publish
- check := me.forge.Repos.FindByGoPath(repo.GoPath())
- if check == nil {
- log.Info("boo, you didn't git clone", repo.GoPath())
- os.Exit(-1)
- }
- match, err := me.forge.Repos.GoDepsChanged(check)
- if err != nil {
- log.Info("dependancy checks failed", check.GetGoPath(), err)
- repo.Status.IncrementRevisionVersion("missing prior published godeps")
- continue
- }
- if match {
- log.Printf("dependancy checks indicate a new release is needed for %s\n", check.GetGoPath())
- repo.Status.IncrementRevisionVersion("godeps changed")
- continue
- } else {
- log.Printf("dependancies have not changed for %s\n", check.GetGoPath())
- }
-
- // see if there is a new version
- master := repo.Status.GetMasterVersion()
- lastTag := repo.Status.LastTag()
- if master == lastTag {
- repo.Status.SetTargetVersion(master)
- } else {
- repo.Status.IncrementRevisionVersion("Nov 2024 test")
- }
- }
- findNext()
- if setAllBranchesToMaster() {
- // if it succeeds, disable this button
- me.setBranchesToMasterB.Disable()
- me.release.box.Enable()
- me.repos.View.PrintReleaseReport("", "")
- } else {
- log.Info("setAllBranchesToMaster() failed")
- }
+ makePrepareRelease()
})
grid.NextRow()
@@ -86,3 +43,50 @@ func globalDisplayOptions(box *gui.Node) {
debugger.DebugWindow()
})
}
+
+func makePrepareRelease() {
+ me.Disable()
+ me.release.box.Disable()
+ defer me.Enable()
+ loop := me.repos.View.ReposSortByName()
+ for loop.Scan() {
+ repo := loop.Repo()
+ // check if the package dependancies changed, if so, re-publish
+ check := me.forge.Repos.FindByGoPath(repo.GoPath())
+ if check == nil {
+ log.Info("boo, you didn't git clone", repo.GoPath())
+ os.Exit(-1)
+ }
+ match, err := me.forge.Repos.GoDepsChanged(check)
+ if err != nil {
+ log.Info("dependancy checks failed", check.GetGoPath(), err)
+ repo.Status.IncrementRevisionVersion("missing prior published godeps")
+ continue
+ }
+ if match {
+ log.Printf("dependancy checks indicate a new release is needed for %s\n", check.GetGoPath())
+ repo.Status.IncrementRevisionVersion("godeps changed")
+ continue
+ } else {
+ log.Printf("dependancies have not changed for %s\n", check.GetGoPath())
+ }
+
+ // see if there is a new version
+ master := repo.Status.GetMasterVersion()
+ lastTag := repo.Status.LastTag()
+ if master == lastTag {
+ repo.Status.SetTargetVersion(master)
+ } else {
+ repo.Status.IncrementRevisionVersion("Nov 2024 test")
+ }
+ }
+ findNext()
+ if setAllBranchesToMaster() {
+ // if it succeeds, disable this button
+ me.setBranchesToMasterB.Disable()
+ me.release.box.Enable()
+ me.repos.View.PrintReleaseReport("", "")
+ } else {
+ log.Info("setAllBranchesToMaster() failed")
+ }
+}
diff --git a/http.go b/http.go
index e4bcccd..924ec1d 100644
--- a/http.go
+++ b/http.go
@@ -155,6 +155,19 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
} else {
repo.Status.Whitelist = true
}
+ case "/testNext":
+ // re-scans the go.sum file. DOES NOT MODIFY ANYTHING
+ check := me.forge.Repos.FindByGoPath(me.current.GoPath())
+ if check == nil {
+ log.Info("boo, you didn't git clone", me.current.GoPath())
+ return
+ }
+ if me.forge.FinalGoDepsCheck(check) {
+ log.Info("finalGoDepsCheck(check) worked!")
+ } else {
+ log.Info("finalGoDepsCheck(check) failed. boo.")
+ }
+ return
case "/showNext":
log.Info("gui repo: " + me.release.repo.String())
log.Info("gui name: " + me.release.version.String())
@@ -166,11 +179,6 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
return
}
- if checkValidGoSum(me.current) {
- log.Info("checkValidGoSum() == true")
- } else {
- log.Info("checkValidGoSum() == false SHOULD NOT RELEASE THIS")
- }
if me.current.Status.IsReleased() {
log.Info("IsReleased() == true SHOULD NOT RELEASE THIS")
} else {
@@ -212,6 +220,7 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
log.Info("Whitelist == false")
}
log.Info("")
+ fixGodeps(me.current)
log.Info(repolist.ReportHeader())
log.Info(me.current.StandardHeader())
diff --git a/main.go b/main.go
index cc531e3..49cb28f 100644
--- a/main.go
+++ b/main.go
@@ -154,6 +154,9 @@ func main() {
}
me.Enable()
+ // set all branches to master & findNext()
+ makePrepareRelease()
+
// intermittently scans the status indefinitly
me.repos.View.Watchdog(func() {
log.Info("In main()")
diff --git a/releaseBox.go b/releaseBox.go
index 1ba48cf..2bfd7fa 100644
--- a/releaseBox.go
+++ b/releaseBox.go
@@ -133,9 +133,9 @@ func createReleaseBox(box *gui.Node) {
findNext()
})
- me.release.checkGoSumB = grid.NewButton("checkValidGoSum()", func() {
+ me.release.checkGoSumB = grid.NewButton("fixGoDeps()", func() {
buttonDisable()
- checkValidGoSum(me.current)
+ fixGodeps(me.current)
buttonEnable()
})
@@ -246,8 +246,7 @@ func createReleaseBox(box *gui.Node) {
if repo.Status.Whitelist {
continue
}
- ok, err := me.repos.View.CheckValidGoSum(repo)
- if !ok {
+ if !goodGodeps(repo) {
log.Info("redo go.sum failed on", repo.GoPath(), err)
worked = false
}