hopefully this logic will finally fucking work
This commit is contained in:
parent
1d6c67b46c
commit
9ee828cc3b
1
argv.go
1
argv.go
|
@ -12,6 +12,7 @@ type args struct {
|
||||||
// Fix bool `arg:"--fix" help:"run fixGoMod() on startup"`
|
// Fix bool `arg:"--fix" help:"run fixGoMod() on startup"`
|
||||||
Minor bool `arg:"--minor" help:"increment minor verion numbers"`
|
Minor bool `arg:"--minor" help:"increment minor verion numbers"`
|
||||||
Protobuf bool `arg:"--protobuf" help:"increment protobuf repos"`
|
Protobuf bool `arg:"--protobuf" help:"increment protobuf repos"`
|
||||||
|
Verbose bool `arg:"--verbose" help:"talk alot"`
|
||||||
Reason string `arg:"--reason" help:"tag message"`
|
Reason string `arg:"--reason" help:"tag message"`
|
||||||
// DumpVersions bool `arg:"--dump-versions" help:"dump the versions file for go.wit.com"`
|
// DumpVersions bool `arg:"--dump-versions" help:"dump the versions file for go.wit.com"`
|
||||||
Port int `arg:"--port" default:"9419" help:"do fun stuff with curl"`
|
Port int `arg:"--port" default:"9419" help:"do fun stuff with curl"`
|
||||||
|
|
|
@ -63,7 +63,7 @@ func doRelease() bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
me.done = append(me.done, me.current.GetGoPath())
|
me.done = append(me.done, me.current.GetGoPath())
|
||||||
if !me.forge.FinalGoDepsCheckOk(check, true) {
|
if err := me.forge.FinalGoDepsCheckOk(check, true); err != nil {
|
||||||
msg := fmt.Sprint("the go.mod file is wrong. fix it here?", check.GetGoPath())
|
msg := fmt.Sprint("the go.mod file is wrong. fix it here?", check.GetGoPath())
|
||||||
badExit(errors.New(msg))
|
badExit(errors.New(msg))
|
||||||
return false
|
return false
|
||||||
|
@ -239,7 +239,7 @@ func doReleaseFindNext() bool {
|
||||||
// if findFix {
|
// if findFix {
|
||||||
// fixGodeps(check)
|
// fixGodeps(check)
|
||||||
// }
|
// }
|
||||||
if me.forge.FinalGoDepsCheckOk(check, false) {
|
if err := me.forge.FinalGoDepsCheckOk(check, false); err == nil {
|
||||||
// the go.sum file is ok to release
|
// the go.sum file is ok to release
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
118
findNext.go
118
findNext.go
|
@ -2,14 +2,10 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
|
||||||
"path/filepath"
|
|
||||||
|
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
|
|
||||||
"go.wit.com/lib/gui/shell"
|
|
||||||
"go.wit.com/lib/protobuf/gitpb"
|
"go.wit.com/lib/protobuf/gitpb"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -17,58 +13,6 @@ var findCounter int
|
||||||
var findFix bool = false
|
var findFix bool = false
|
||||||
var findOk bool = true
|
var findOk bool = 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.RunVerbose([]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.RunVerboseOnError([]string{"go-mod-clean", "--restore"})
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
log.Info("go-mod-clean restore worked ", repo.GetGoPath())
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func slowRestore() error {
|
|
||||||
all := me.forge.Repos.All()
|
|
||||||
for all.Scan() {
|
|
||||||
repo := all.Next()
|
|
||||||
if err := rillRestore(repo); err != nil {
|
|
||||||
badExit(err)
|
|
||||||
}
|
|
||||||
if repo.ParseGoSum() {
|
|
||||||
log.Info("go-mod-clean and parse worked", repo.GetGoPath())
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func checkDeps(repo *gitpb.Repo) error {
|
func checkDeps(repo *gitpb.Repo) error {
|
||||||
if repo.GoDeps == nil {
|
if repo.GoDeps == nil {
|
||||||
return fmt.Errorf("%s has GoDeps == nil", repo.GetGoPath())
|
return fmt.Errorf("%s has GoDeps == nil", repo.GetGoPath())
|
||||||
|
@ -121,8 +65,15 @@ func findNext() bool {
|
||||||
log.Info("CAN NOT RELEASE DIRTY REPO", check.GetGoPath())
|
log.Info("CAN NOT RELEASE DIRTY REPO", check.GetGoPath())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if alreadyDone(check) {
|
||||||
|
log.Info("findNext() ALREADY DONE. WHY IS THIS STILL CHECKING?", check.GetGoPath())
|
||||||
|
log.Info("findNext() ALREADY DONE. WHY IS THIS STILL CHECKING?", check.GetGoPath())
|
||||||
|
log.Info("findNext() ALREADY DONE. WHY IS THIS STILL CHECKING?", check.GetGoPath())
|
||||||
|
continue
|
||||||
|
}
|
||||||
log.Info("CHECKING:", check.GetGoPath())
|
log.Info("CHECKING:", check.GetGoPath())
|
||||||
_, err := check.RunVerboseOnError([]string{"go-mod-clean", "--strict"})
|
// _, err := check.RunVerboseOnError([]string{"go-mod-clean", "--strict"})
|
||||||
|
_, err := check.RunStrictNew([]string{"go-mod-clean", "--strict"})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Info("FAILED:", check.GetGoPath())
|
log.Info("FAILED:", check.GetGoPath())
|
||||||
continue
|
continue
|
||||||
|
@ -141,7 +92,7 @@ func findNext() bool {
|
||||||
log.Info("ParseGoSum() failed", check.GetGoPath())
|
log.Info("ParseGoSum() failed", check.GetGoPath())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if me.forge.FinalGoDepsCheckOk(check, false) {
|
if err := me.forge.FinalGoDepsCheckOk(check, argv.Verbose); err == nil {
|
||||||
log.Info("GOOD TO GO ON", check.GetGoPath())
|
log.Info("GOOD TO GO ON", check.GetGoPath())
|
||||||
setCurrentRepo(check, "should be good to release", "pretty sure")
|
setCurrentRepo(check, "should be good to release", "pretty sure")
|
||||||
return true
|
return true
|
||||||
|
@ -163,50 +114,25 @@ func findNext() bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func runGoClean(check *gitpb.Repo, myarg string) bool {
|
|
||||||
// check if the package dependancies changed, if so, re-publish
|
|
||||||
check.GoDeps = nil
|
|
||||||
|
|
||||||
cmd := []string{"go-mod-clean", myarg}
|
|
||||||
// log.Info("Running", cmd, "in", check.GetGoPath())
|
|
||||||
result := check.Run(cmd)
|
|
||||||
if result.Error != nil {
|
|
||||||
/*
|
|
||||||
log.Info(cmd, "failed with", result.Error, check.GetGoPath())
|
|
||||||
log.Info("STDOUT")
|
|
||||||
log.Info(strings.Join(result.Stdout, "\n"))
|
|
||||||
log.Info("STDERR")
|
|
||||||
log.Info(strings.Join(result.Stderr, "\n"))
|
|
||||||
*/
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if result.Exit != 0 {
|
|
||||||
/*
|
|
||||||
log.Info(cmd, "failed with", result.Exit, check.GetGoPath())
|
|
||||||
log.Info("STDOUT")
|
|
||||||
log.Info(strings.Join(result.Stdout, "\n"))
|
|
||||||
log.Info("STDERR")
|
|
||||||
log.Info(strings.Join(result.Stderr, "\n"))
|
|
||||||
*/
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if check.ParseGoSum() {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
log.Info("ParseGoSum() failed", check.GetGoPath())
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// tries to fix the go.mod and go.sum files
|
// tries to fix the go.mod and go.sum files
|
||||||
func fixGodeps(check *gitpb.Repo) bool {
|
func fixGodeps(check *gitpb.Repo) bool {
|
||||||
log.Info("fixGoDeps() START", check.GetGoPath())
|
log.Info("fixGoDeps() START", check.GetGoPath())
|
||||||
log.Info("fixGoDeps() START", check.GetGoPath())
|
log.Info("fixGoDeps() START", check.GetGoPath())
|
||||||
log.Info("fixGoDeps() START", check.GetGoPath())
|
log.Info("fixGoDeps() START", check.GetGoPath())
|
||||||
var good bool = true
|
var good bool = true
|
||||||
if !runGoClean(check, "--strict") {
|
|
||||||
log.Info("fixGoDeps() runGoClean() strict failed", check.GetGoPath())
|
check.GoDeps = nil
|
||||||
log.Info("fixGoDeps() runGoClean() strict failed", check.GetGoPath())
|
|
||||||
log.Info("fixGoDeps() runGoClean() strict failed", check.GetGoPath())
|
if _, err := check.RunVerboseOnError([]string{"go-mod-clean", "--strict"}); err != nil {
|
||||||
|
log.Info("fixGoDeps() runGoClean() strict failed", check.GetGoPath(), err)
|
||||||
|
log.Info("fixGoDeps() runGoClean() strict failed", check.GetGoPath(), err)
|
||||||
|
log.Info("fixGoDeps() runGoClean() strict failed", check.GetGoPath(), err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if check.ParseGoSum() {
|
||||||
|
return true
|
||||||
|
} else {
|
||||||
|
log.Info("ParseGoSum() failed", check.GetGoPath())
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
// skip primative ones
|
// skip primative ones
|
||||||
|
|
2
http.go
2
http.go
|
@ -121,7 +121,7 @@ func testGoRepo(check *gitpb.Repo) {
|
||||||
data, _ := os.ReadFile(filepath.Join(check.FullPath, "go.mod"))
|
data, _ := os.ReadFile(filepath.Join(check.FullPath, "go.mod"))
|
||||||
log.Info(string(data))
|
log.Info(string(data))
|
||||||
|
|
||||||
if me.forge.FinalGoDepsCheckOk(check, true) {
|
if err := me.forge.FinalGoDepsCheckOk(check, true); err == nil {
|
||||||
log.Info("forge.FinalGoDepsCheck(check) worked!")
|
log.Info("forge.FinalGoDepsCheck(check) worked!")
|
||||||
} else {
|
} else {
|
||||||
log.Info("forge.FinalGoDepsCheck(check) failed. boo.")
|
log.Info("forge.FinalGoDepsCheck(check) failed. boo.")
|
||||||
|
|
6
main.go
6
main.go
|
@ -66,6 +66,12 @@ func main() {
|
||||||
|
|
||||||
// our main window
|
// our main window
|
||||||
me.mainWindow = me.myGui.NewWindow("GUI release manager " + VERSION)
|
me.mainWindow = me.myGui.NewWindow("GUI release manager " + VERSION)
|
||||||
|
me.mainWindow.Custom = func() {
|
||||||
|
log.Warn("Window closed. forge configsave")
|
||||||
|
// sets the hidden flag to false so Toggle() works
|
||||||
|
me.forge.ConfigSave()
|
||||||
|
okExit("")
|
||||||
|
}
|
||||||
me.mainBox = me.mainWindow.NewBox("bw hbox", true)
|
me.mainBox = me.mainWindow.NewBox("bw hbox", true)
|
||||||
|
|
||||||
// start the http server for polling status
|
// start the http server for polling status
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"go.wit.com/lib/gui/shell"
|
"go.wit.com/lib/gui/shell"
|
||||||
|
@ -16,13 +18,47 @@ func forceReleaseVersion(repo *gitpb.Repo) {
|
||||||
repo.IncrementTargetMinor()
|
repo.IncrementTargetMinor()
|
||||||
} else {
|
} else {
|
||||||
// if v1.2.3 change to v.1.2.4
|
// if v1.2.3 change to v.1.2.4
|
||||||
if repo.IncrementTargetRevision() {
|
repo.IncrementTargetRevision()
|
||||||
// worked ok
|
|
||||||
} else {
|
|
||||||
log.Info("Failed to increment target revision", repo.GetFullPath())
|
|
||||||
os.Exit(-1)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
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() {
|
func rePrepareRelease() {
|
||||||
|
@ -32,13 +68,22 @@ func rePrepareRelease() {
|
||||||
|
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
me.forge.RillFuncError(rillRestore)
|
me.forge.RillFuncError(rillRestore)
|
||||||
// slowRestore()
|
|
||||||
log.Printf("showRestore() (%d total repos) took:%s\n", me.forge.Repos.Len(), shell.FormatDuration(time.Since(now)))
|
log.Printf("showRestore() (%d total repos) took:%s\n", me.forge.Repos.Len(), shell.FormatDuration(time.Since(now)))
|
||||||
|
|
||||||
all := me.forge.Repos.SortByFullPath()
|
all := me.forge.Repos.SortByFullPath()
|
||||||
for all.Scan() {
|
for all.Scan() {
|
||||||
check := all.Next()
|
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()) {
|
if me.forge.Config.IsReadOnly(check.GetGoPath()) {
|
||||||
// can't release readonly repos
|
// can't release readonly repos
|
||||||
continue
|
continue
|
||||||
|
@ -47,21 +92,30 @@ func rePrepareRelease() {
|
||||||
master := check.GetMasterVersion()
|
master := check.GetMasterVersion()
|
||||||
lastTag := check.GetLastTag()
|
lastTag := check.GetLastTag()
|
||||||
if master != lastTag {
|
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)
|
forceReleaseVersion(check)
|
||||||
me.found.AppendByGoPath(check)
|
me.found.AppendByGoPath(check)
|
||||||
continue
|
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.Quick != nil {
|
||||||
// if argv has 'quick' don't do anything
|
// if argv has 'quick' don't do anything
|
||||||
// that doesn't actually have a patch
|
// that doesn't actually have a patch
|
||||||
|
@ -71,6 +125,7 @@ func rePrepareRelease() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if argv.Protobuf && check.GetRepoType() == "protobuf" {
|
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
|
// if --protobuf, this will force upgrade each one
|
||||||
forceReleaseVersion(check)
|
forceReleaseVersion(check)
|
||||||
me.found.AppendByGoPath(check)
|
me.found.AppendByGoPath(check)
|
||||||
|
@ -81,14 +136,14 @@ func rePrepareRelease() {
|
||||||
// any library version change
|
// any library version change
|
||||||
// if check.GetRepoType() == "binary" || check.GetRepoType() == "plugin" {
|
// if check.GetRepoType() == "binary" || check.GetRepoType() == "plugin" {
|
||||||
// check if the package dependancies changed, if so, re-publish
|
// check if the package dependancies changed, if so, re-publish
|
||||||
if me.forge.FinalGoDepsCheckOk(check, false) {
|
if err := me.forge.FinalGoDepsCheckOk(check, false); err == nil {
|
||||||
log.Printf("go.sum is perfect! %s\n", check.GetGoPath())
|
// log.Printf("go.sum is perfect! %s\n", check.GetGoPath())
|
||||||
continue
|
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)
|
me.forge.PrintHumanTable(me.found)
|
||||||
|
|
Loading…
Reference in New Issue