summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-02-08 06:32:37 -0600
committerJeff Carr <[email protected]>2025-02-08 06:32:37 -0600
commit8cc487393f0ab7a33c3305cd7cd39c6ac35c9072 (patch)
treee896cf1b002a39afd9de4558c3ece66979dca7f3
parent021c7774b2b66c8fe989d27f13ea5b1fd2dbd94c (diff)
checks for more things
-rw-r--r--main.go2
-rw-r--r--prepareRelease.go100
2 files changed, 102 insertions, 0 deletions
diff --git a/main.go b/main.go
index 7b6f78c..9fd672d 100644
--- a/main.go
+++ b/main.go
@@ -113,6 +113,8 @@ func main() {
badExit(errors.New(msg))
}
+ me.forge.RillFuncError(rillPurge)
+
// run this each time something gets published successfully
rePrepareRelease()
diff --git a/prepareRelease.go b/prepareRelease.go
index 4f26595..f86cfc0 100644
--- a/prepareRelease.go
+++ b/prepareRelease.go
@@ -2,6 +2,7 @@ package main
import (
"errors"
+ "fmt"
"os"
"path/filepath"
"time"
@@ -43,6 +44,23 @@ func checkpkgcache(repo *gitpb.Repo) error {
var rillcount int
+func rillPurge(repo *gitpb.Repo) error {
+ if me.forge.Config.IsReadOnly(repo.GetGoPath()) {
+ return nil
+ }
+ if me.forge.Config.IsPrivate(repo.GetGoPath()) {
+ return nil
+ }
+
+ _, err := repo.RunQuiet([]string{"go-mod-clean", "--purge"})
+ rillcount += 1
+ if err != nil {
+ log.Info("go-mod-clean --smart failed", repo.GetGoPath(), err)
+ return err
+ }
+ return nil
+}
+
func rillRestore(repo *gitpb.Repo) error {
if me.forge.Config.IsReadOnly(repo.GetGoPath()) {
return nil
@@ -102,6 +120,20 @@ func rePrepareRelease() {
// can't release readonly repos
continue
}
+
+ if !me.forge.Config.IsPrivate(check.GetGoPath()) {
+ if err := checkPublishedGodeps(check); err != nil {
+ // this means the published godeps are no longer up to date
+ forceReleaseVersion(check)
+ me.found.AppendByGoPath(check)
+ log.Info("checkPublishedGodeps failed with err", check.GetGoPath(), err)
+ okExit("")
+ continue
+ } else {
+ // log.Info("checkPublishedGodeps is ok", check.GetGoPath())
+ }
+ }
+
// if master != lastTag, always increment
master := check.GetMasterVersion()
lastTag := check.GetLastTag()
@@ -187,3 +219,71 @@ func alreadyDone(repo *gitpb.Repo) bool {
}
return false
}
+
+func checkPublishedGodeps(repo *gitpb.Repo) error {
+ godepsOld, err := repo.GoSumFromPkgDir()
+ if err != nil {
+ return err
+ }
+ if godepsOld != nil {
+ if err := me.forge.TestGoDepsCheckOk(godepsOld, argv.Verbose); err != nil {
+ return err
+ }
+ /*
+ all := godepsOld.All()
+ for all.Scan() {
+ dep := all.Next()
+ // log.Info(repo.GetGoPath(), dep.GoPath, dep.Version)
+
+ // check if the package in question is waiting for another package to publish
+ found := me.forge.FindByGoPath(dep.GoPath)
+ if found == nil {
+ return fmt.Errorf("%s has godep %s which can not be found", repo.GetGoPath(), dep.GoPath)
+ }
+ if found.GetLastTag() != dep.Version {
+ return fmt.Errorf("%s with godep %s version mismatch %s vs %s", repo.GetGoPath(), dep.GoPath, found.GetLastTag(), dep.Version)
+ }
+ }
+ */
+ }
+ godepsNew, err := repo.GoSumFromRepo()
+ if err != nil {
+ return err
+ }
+ if godepsOld == nil {
+ if godepsNew == nil {
+ log.Printf("%s published godeps == nil && real == nil\n", repo.GetGoPath())
+ return nil
+ } else {
+ return fmt.Errorf("published godeps == nil vs real != nil")
+ }
+ }
+ if err := me.forge.TestGoDepsCheckOk(godepsNew, argv.Verbose); err != nil {
+ return err
+ }
+ return nil
+}
+
+/*
+func checkGodeps(repo *gitpb.Repo, godeps *gitpb.GoDeps) error {
+ if godeps == nil {
+ }
+ return nil
+ all := godeps.All()
+ for all.Scan() {
+ dep := all.Next()
+ // log.Info(repo.GetGoPath(), dep.GoPath, dep.Version)
+
+ // check if the package in question is waiting for another package to publish
+ found := me.forge.FindByGoPath(dep.GoPath)
+ if found == nil {
+ return fmt.Errorf("%s has godep %s which can not be found", repo.GetGoPath(), dep.GoPath)
+ }
+ if found.GetLastTag() != dep.Version {
+ return fmt.Errorf("%s with godep %s version mismatch %s vs %s", repo.GetGoPath(), dep.GoPath, found.GetLastTag(), dep.Version)
+ }
+ log.Printf("%s with godep %s version match %s vs %s\n", repo.GetGoPath(), dep.GoPath, found.GetLastTag(), dep.Version)
+ }
+ return nil
+}
+*/