summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-10-30 14:02:49 -0500
committerJeff Carr <[email protected]>2025-10-30 14:02:49 -0500
commit5ff57a4aaa914eac08f25c5323bb1bb1f2bcb7be (patch)
tree8ba2929f9440147beabbbdac2a66252d00f491a0
parent616b7914ffbac9512bcb230a56ee87e84b4100d6 (diff)
-rw-r--r--finalGoDepsCheckOk.go9
-rw-r--r--findNext.go1
-rw-r--r--prepareRelease.go6
-rw-r--r--prepareReleaseNew.go113
4 files changed, 121 insertions, 8 deletions
diff --git a/finalGoDepsCheckOk.go b/finalGoDepsCheckOk.go
index 6cdbaec..19c54eb 100644
--- a/finalGoDepsCheckOk.go
+++ b/finalGoDepsCheckOk.go
@@ -3,24 +3,19 @@ package main
import (
"errors"
"fmt"
- "os"
"path/filepath"
"go.wit.com/lib/env"
"go.wit.com/lib/protobuf/gitpb"
- "go.wit.com/log"
)
func finalGoDepsCheckOk(check *gitpb.Repo) error {
- data, _ := os.ReadFile(filepath.Join(check.FullPath, "go.mod"))
- log.Info(string(data))
-
err := me.forge.FinalGoDepsCheckOk(check)
if err == nil {
- log.Info("FINDNEXT: forge.FinalGoDepsCheck(check) worked!")
+ // log.Info("FINDNEXT: forge.FinalGoDepsCheck(check) worked!")
return nil
}
- log.Printf("FINDNEXT: forge.FinalGoDepsCheck(check) err (%v)\n", err)
+ // log.Printf("FINDNEXT: forge.FinalGoDepsCheck(check) err (%v)\n", err)
return err
}
diff --git a/findNext.go b/findNext.go
index 775ec4f..c73cc2c 100644
--- a/findNext.go
+++ b/findNext.go
@@ -53,6 +53,7 @@ func findNext() bool {
err := check.RunVerbose(cmd)
if err != nil {
log.Info("FIND NEXT: go mod tidy failed. this go package needs to be examined by hand as it doesn't appear to be primitive")
+ log.Info("FIND NEXT:", check.FullPath, cmd)
os.Exit(-1)
}
// if godepsNew == nil, then this go package is a primitive and there is no go.sum file
diff --git a/prepareRelease.go b/prepareRelease.go
index 4488935..422f9f5 100644
--- a/prepareRelease.go
+++ b/prepareRelease.go
@@ -260,6 +260,9 @@ func alreadyDone(repo *gitpb.Repo) bool {
return false
}
+// checks the published go.* files in ~/go/pkg/mod
+// checks the go.* files currently on disk in ~/go/src
+// TODO: compare these to each other // TODO: this is probably the missing piece to this whole thing not working right yet
func checkPublishedGodeps(repo *gitpb.Repo) error {
godepsOld, err := repo.GoSumFromPkgDir()
if err != nil {
@@ -276,7 +279,8 @@ func checkPublishedGodeps(repo *gitpb.Repo) error {
}
if godepsOld == nil {
if godepsNew == nil {
- log.Printf("%s published godeps == nil && real == nil\n", repo.GetGoPath())
+ // log.Printf("%s published godeps == nil && real == nil\n", repo.GetGoPath())
+ // is primative. probably very certainly so. this check seems to work
return nil
} else {
return fmt.Errorf("published godeps == nil vs real != nil")
diff --git a/prepareReleaseNew.go b/prepareReleaseNew.go
new file mode 100644
index 0000000..5743c71
--- /dev/null
+++ b/prepareReleaseNew.go
@@ -0,0 +1,113 @@
+package main
+
+import (
+ "errors"
+
+ "go.wit.com/lib/protobuf/gitpb"
+ "go.wit.com/log"
+)
+
+func rePrepareReleaseNew(check *gitpb.Repo) error {
+ // me.forge.RillFuncError(rillRestore)
+ var test string
+
+ if check.FullPath == "/home/jcarr/go/src/go.wit.com/lib/virtigolib" {
+ test = "bob"
+ }
+
+ if alreadyDone(check) {
+ // means it was already published
+ // protects against logic errors that might result
+ // in an infinite loop
+ log.Info("WARNING alreadyDone rePrepareRelease()", check.GetGoPath())
+ return nil
+ }
+
+ if me.forge.Config.IsReadOnly(check.GetGoPath()) {
+ // can't release readonly repos
+ return nil
+ }
+
+ master := check.GetMasterVersion()
+ lastTag := check.GetLastTag()
+
+ if master != lastTag {
+ log.Info("LAST TAG != master", check.FullPath, master, lastTag)
+ } else {
+ }
+
+ if me.forge.Config.IsPrivate(check.GetGoPath()) {
+ if master != lastTag {
+ return errors.New("adding private repo: " + check.FullPath)
+
+ }
+ return nil
+ }
+ // this is detailed. It makes sure the go.* files are absolutely perfect
+ if err := checkPublishedGodeps(check); err != nil {
+ // this means the published godeps are no longer up to date
+ // forceReleaseVersion(check)
+ // log.Info("checkPublishedGodeps failed with err", check.GetGoPath(), err)
+ return err
+ }
+
+ // if master != lastTag, always increment
+ if master != lastTag {
+ newmhash := check.GetTagHash(master)
+ oldlhash := check.GetTagHash(lastTag)
+ if newmhash == oldlhash {
+ // they are actually equal
+ return nil
+ }
+ b1, err := check.CountDiffObjects(oldlhash, newmhash)
+ if err != nil {
+ badExit(err)
+ }
+ b2, err := check.CountDiffObjects(newmhash, oldlhash)
+ if err != nil {
+ badExit(err)
+ }
+ if b1 != 0 {
+ log.Printf("HASH ERROR %-50s tag %s < %s\n", check.GetGoPath(), newmhash, oldlhash)
+ log.Info("old vs new count", b1, b2, "git merge", oldlhash)
+ }
+
+ if b1 == 0 && b2 == 0 {
+ log.Info("got to identical repo", check.GetGoPath(), b1, b2)
+ log.Info("got to identical repo", check.GetGoPath(), oldlhash, newmhash)
+ // actually identical. do nothing
+ return nil
+ }
+ if gitpb.IsGoTagVersionGreater(lastTag, master) {
+ // this function is not right really. the hash error above should catch it correctly
+ // log.Printf("PROBABLY NOT NEE %-50s tag %s < %s\n", check.GetGoPath(), lastTag, master)
+ return errors.New("gitpb.IsGoTagVersionGreater(lastTag, master)")
+ }
+ log.Printf("NEED RELEASE FOR TAG %-50s tag %s != %s\n", check.GetGoPath(), master, lastTag)
+ // forceReleaseVersion(check)
+ return errors.New("master != lastTag")
+ }
+
+ if argv.Protobuf && check.GetRepoType() == "protobuf" {
+ log.Printf("NEED RELEASE FOR TYPE %s err: %v\n", check.GetGoPath(), "because --protobuf")
+ // if --protobuf, this will force upgrade each one
+ // forceReleaseVersion(check)
+ // me.found.AppendByFullPath(check)
+ return errors.New("protobuf repo deps changed")
+ }
+
+ // if the repo is a go binary or plugin for a new release for
+ // any library version change
+ // if check.GetRepoType() == "binary" || check.GetRepoType() == "plugin" {
+ // check if the package dependancies changed, if so, re-publish
+ if err := finalGoDepsCheckOk(check); err == nil {
+ // log.Printf("go.sum is perfect! %s\n", check.GetGoPath())
+ return nil
+ } else {
+ log.Printf("NEED RELEASE FOR CHECK %-50s err: %v\n", check.GetGoPath(), err)
+ log.Println("RETURNING ERROR IN IN me.forge.RunOnReposNew() rePrepareReleaseNew(check) for", check.FullPath)
+ log.Println("bob = ", test)
+ return errors.New("FinalGoDepsCheckOk() failed even though master tag == last tag")
+ }
+ return nil
+}