diff options
Diffstat (limited to 'prepareRelease.go')
| -rw-r--r-- | prepareRelease.go | 101 |
1 files changed, 78 insertions, 23 deletions
diff --git a/prepareRelease.go b/prepareRelease.go index 162fd85..78b2678 100644 --- a/prepareRelease.go +++ b/prepareRelease.go @@ -1,7 +1,9 @@ package main import ( + "errors" "os" + "path/filepath" "time" "go.wit.com/lib/gui/shell" @@ -16,13 +18,47 @@ func forceReleaseVersion(repo *gitpb.Repo) { repo.IncrementTargetMinor() } else { // if v1.2.3 change to v.1.2.4 - if repo.IncrementTargetRevision() { - // worked ok - } else { - log.Info("Failed to increment target revision", repo.GetFullPath()) - os.Exit(-1) - } + repo.IncrementTargetRevision() } + me.forge.SetConfigSave(true) +} + +func checkpkgcache(repo *gitpb.Repo) error { + homedir, err := os.UserHomeDir() + if err != nil { + return err + } + rver := repo.GetLastTag() + if rver == "" { + return errors.New("could not get master version") + } + moddir := filepath.Join(homedir, "go/pkg/mod", repo.GetGoPath()+"@"+rver) + if shell.IsDir(moddir) { + return nil + } + + getpath := repo.GetGoPath() + "@" + repo.GetLastTag() + _, err = me.startRepo.RunVerboseOnError([]string{"go", "get", getpath}) + return err +} + +func rillRestore(repo *gitpb.Repo) error { + if me.forge.Config.IsReadOnly(repo.GetGoPath()) { + return nil + } + if me.forge.Config.IsPrivate(repo.GetGoPath()) { + return nil + } + if err := checkpkgcache(repo); err != nil { + return err + } + _, err := repo.RunStrictNew([]string{"go-mod-clean", "--restore"}) + if err != nil { + log.Info("go-mod-clean --restore failed", repo.GetGoPath(), err) + return err + } + // log.Info("go-mod-clean --restore worked ", repo.GetGoPath()) + return nil } func rePrepareRelease() { @@ -32,13 +68,22 @@ func rePrepareRelease() { now := time.Now() me.forge.RillFuncError(rillRestore) - // slowRestore() log.Printf("showRestore() (%d total repos) took:%s\n", me.forge.Repos.Len(), shell.FormatDuration(time.Since(now))) all := me.forge.Repos.SortByFullPath() for all.Scan() { check := all.Next() + if alreadyDone(check) { + // means it was already published + // protects against logic errors that might result + // in an infinite loop + log.Info("WARNING already done", check.GetGoPath()) + log.Info("WARNING already done", check.GetGoPath()) + log.Info("WARNING already done", check.GetGoPath()) + continue + } + if me.forge.Config.IsReadOnly(check.GetGoPath()) { // can't release readonly repos continue @@ -47,21 +92,30 @@ func rePrepareRelease() { master := check.GetMasterVersion() lastTag := check.GetLastTag() if master != lastTag { + newmhash := check.GetTagHash(master) + oldlhash := check.GetTagHash(lastTag) + if newmhash == oldlhash { + // they are actually equal + continue + } + b1 := check.CountDiffObjects(oldlhash, newmhash) + b2 := check.CountDiffObjects(newmhash, oldlhash) + 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 { + 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) + } + log.Printf("NEED RELEASE FOR %-50s tag %s != %s\n", check.GetGoPath(), master, lastTag) forceReleaseVersion(check) me.found.AppendByGoPath(check) continue } - if alreadyDone(check) { - // means it was already published - // protects against logic errors that might result - // in an infinite loop - log.Info("WARNING already done", check.GetGoPath()) - log.Info("WARNING already done", check.GetGoPath()) - log.Info("WARNING already done", check.GetGoPath()) - continue - } - if argv.Quick != nil { // if argv has 'quick' don't do anything // that doesn't actually have a patch @@ -71,6 +125,7 @@ func rePrepareRelease() { } if argv.Protobuf && check.GetRepoType() == "protobuf" { + log.Printf("NEED RELEASE FOR %s err: %v\n", check.GetGoPath(), "because --protobuf") // if --protobuf, this will force upgrade each one forceReleaseVersion(check) me.found.AppendByGoPath(check) @@ -81,14 +136,14 @@ func rePrepareRelease() { // any library version change // if check.GetRepoType() == "binary" || check.GetRepoType() == "plugin" { // check if the package dependancies changed, if so, re-publish - if me.forge.FinalGoDepsCheckOk(check, false) { - log.Printf("go.sum is perfect! %s\n", check.GetGoPath()) + if err := me.forge.FinalGoDepsCheckOk(check, false); err == nil { + // log.Printf("go.sum is perfect! %s\n", check.GetGoPath()) continue + } else { + log.Printf("NEED RELEASE FOR %-50s err: %v\n", check.GetGoPath(), err) + forceReleaseVersion(check) + me.found.AppendByGoPath(check) } - log.Printf("dependancy checks indicate a new release is needed for %s\n", check.GetGoPath()) - forceReleaseVersion(check) - me.found.AppendByGoPath(check) - // } } me.forge.PrintHumanTable(me.found) |
