keep switching to protobuf

This commit is contained in:
Jeff Carr 2024-12-12 02:05:47 -06:00
parent 2d981da765
commit 6e9ff62fba
5 changed files with 53 additions and 149 deletions

View File

@ -36,13 +36,6 @@ func doRelease() bool {
} else { } else {
log.Info("go.mod missing") log.Info("go.mod missing")
return false 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() curName := me.current.Status.GetCurrentBranchName()
@ -206,16 +199,16 @@ func doPublishVersion() bool {
docmd := []string{"go", "get", "-v", gopath + "@" + me.release.version.String()} docmd := []string{"go", "get", "-v", gopath + "@" + me.release.version.String()}
log.Info("SHOULD RUN cmd HERE:", docmd) log.Info("SHOULD RUN cmd HERE:", docmd)
// right now, you can't publish this because the go.* files in this project are screwed up testf := filepath.Join(me.forge.GetGoSrc(), "go.wit.com/apps/guireleaser", "go.sum")
if me.release.guireleaser == nil { if !shell.Exists(testf) {
log.Info("CAN NOT SELF UPDATE HERE. cmd =", docmd) pb := me.forge.Repos.FindByGoPath("go.wit.com/apps/guireleaser")
return false if pb != nil {
} pb.RedoGoMod() // hack for reset on guireleaser while publishing
homeDir, _ := os.UserHomeDir() }
gosum := filepath.Join(homeDir, "go/src/go.wit.com/apps/guireleaser/go.sum") if !shell.Exists(testf) {
if !shell.Exists(gosum) { log.Info("go.sum missing", testf)
log.Info("go.sum must exist here") panic("redo go.sum")
me.release.guireleaser.MakeRedoMod() }
} }
if me.current.Status.IsPrivate() { if me.current.Status.IsPrivate() {
// do not self update private repos // do not self update private repos

View File

@ -101,25 +101,26 @@ func findNext() bool {
func fixGodeps(check *gitpb.Repo) bool { func fixGodeps(check *gitpb.Repo) bool {
var good bool = true var good bool = true
// check if the package dependancies changed, if so, re-publish // check if the package dependancies changed, if so, re-publish
cmd := []string{"go-clean", "--auto"}
result := check.RunRealtime(cmd)
if result.Error != nil {
log.Info(cmd, "failed with", result.Error, check.GoPath)
return false
}
if result.Exit != 0 {
log.Info(cmd, "failed with", result.Exit, check.GoPath)
return false
}
check.GoDeps = nil
// skip primative ones // skip primative ones
if ok, _ := check.IsPrimitive(); ok { if ok, _ := check.IsPrimitive(); ok {
log.Info("fixGoDeps() skipping primitive", check.GoPath) log.Info("fixGoDeps() skipping primitive", check.GoPath)
return true return true
} }
ok, err := check.RedoGoMod() if ok, err := check.ParseGoSum(); !ok {
if err != nil { log.Info("ParseGoSum() failed", err)
log.Info("fixGoDeps() RedoGoMod() error", err)
return false return false
} }
if !ok {
log.Info("gitpb.RedoGoMod() returned false", check.GetGoPath())
return false
}
if check.GoDeps == nil {
cmd := []string{"go", "mod", "edit", "-go=1.20"}
check.Run(cmd)
return true
}
log.Printf("current repo %s go dependancy count: %d", check.GetGoPath(), check.GoDepsLen()) log.Printf("current repo %s go dependancy count: %d", check.GetGoPath(), check.GoDepsLen())
deps := check.GoDeps.SortByGoPath() deps := check.GoDeps.SortByGoPath()
for deps.Scan() { for deps.Scan() {
@ -143,15 +144,6 @@ func fixGodeps(check *gitpb.Repo) bool {
check.Run(cmd) check.Run(cmd)
} }
} }
cmd := []string{"go", "mod", "tidy"}
check.Run(cmd)
cmd = []string{"go", "mod", "edit", "-go=1.20"}
check.Run(cmd)
check.GoDeps = nil
if ok, err := check.ParseGoSum(); !ok {
log.Info("ParseGoSum() failed", err)
return false
}
return good return good
} }

View File

@ -1,8 +1,6 @@
package main package main
import ( import (
"os"
"go.wit.com/log" "go.wit.com/log"
) )
@ -20,109 +18,54 @@ func makePrepareRelease() {
log.Info("setAllBranchesToMaster() failed") log.Info("setAllBranchesToMaster() failed")
} }
// first reset all the target versions back to the current version // reset all the target versions back to the current version
// incase there was a partial release process running that // incase they were saved in the repos.pb file
// did not finish all := me.forge.Repos.SortByGoPath()
loop := me.repos.View.ReposSortByName() for all.Scan() {
for loop.Scan() { check := all.Next()
repo := loop.Repo()
// find the gitpb.Repo
check := me.forge.Repos.FindByGoPath(repo.GoPath())
if check == nil {
log.Info("boo, you didn't git clone", repo.GoPath())
os.Exit(-1)
}
// set the target version to the current master version // set the target version to the current master version
curver := repo.Status.GetMasterVersion() curver := check.GetMasterVersion()
check.SetTargetVersion(curver) check.SetTargetVersion(curver)
} }
// on startup, run fixGoDeps() on every go.sum that didn't match // on startup, run fixGoDeps() on every go.sum that didn't match
if argv.Fix { if argv.Fix {
loop = me.repos.View.ReposSortByName() all := me.forge.Repos.SortByGoPath()
for loop.Scan() { for all.Scan() {
repo := loop.Repo() check := all.Next()
// find the gitpb.Repo
check := me.forge.Repos.FindByGoPath(repo.GoPath())
if check == nil {
log.Info("boo, you didn't git clone", repo.GoPath())
os.Exit(-1)
}
if !me.forge.FinalGoDepsCheckOk(check) { if !me.forge.FinalGoDepsCheckOk(check) {
fixGodeps(check) fixGodeps(check)
} }
} }
} }
// now figure out what to release and increment the version all = me.forge.Repos.SortByGoPath()
loop = me.repos.View.ReposSortByName() for all.Scan() {
for loop.Scan() { check := all.Next()
repo := loop.Repo()
// find the gitpb.Repo // if master != lastTag, always increment
check := me.forge.Repos.FindByGoPath(repo.GoPath()) master := check.GetMasterVersion()
if check == nil { lastTag := check.GetLastTag()
log.Info("boo, you didn't git clone", repo.GoPath()) if master != lastTag {
os.Exit(-1) // if v1.2.3 change to v.1.2.4
check.IncrementTargetRevision()
continue
} }
// if check.GetGoPath() == "go.wit.com/dev/alexflint/arg" { // if the repo is a go binary, try forcing new go.* files
if check.GetGoPath() == "go.wit.com/gui" { if check.RepoType() == "binary" {
log.Info("arg", check.GetGoPath(), check.GetMasterVersion(), check.GoPrimitive) // check if the package dependancies changed, if so, re-publish
if me.forge.FinalGoDepsCheckOk(check) {
log.Info("arg final check true", check.GetGoPath())
} else {
log.Info("arg final check false", check.GetGoPath())
// os.Exit(-1)
}
// see if there is a new version
master := repo.Status.GetMasterVersion()
lastTag := repo.Status.LastTag()
log.Info("arg ", master, lastTag)
// os.Exit(-1)
}
// check if the package dependancies changed, if so, re-publish
if !check.GoPrimitive {
if me.forge.FinalGoDepsCheckOk(check) { if me.forge.FinalGoDepsCheckOk(check) {
log.Printf("go.sum is perfect! %s\n", check.GetGoPath()) log.Printf("go.sum is perfect! %s\n", check.GetGoPath())
} else { } else {
log.Printf("dependancy checks indicate a new release is needed for %s\n", check.GetGoPath()) log.Printf("dependancy checks indicate a new release is needed for %s\n", check.GetGoPath())
repo.Status.IncrementRevisionVersion("godeps changed") // if v1.2.3 change to v.1.2.4
target := repo.Status.GetTargetVersion() check.IncrementTargetRevision()
check.SetTargetVersion(target)
} }
} }
// 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")
target := repo.Status.GetTargetVersion()
check.SetTargetVersion(target)
}
// if check.GetGoPath() == "go.wit.com/dev/alexflint/arg" {
// if check.GetGoPath() == "go.wit.com/gui" {
if check.GetGoPath() == "go.wit.com/dev/davecgh/spew" {
log.Info(repo.StandardReleaseHeader())
log.Info(me.forge.StandardReleaseHeader(check, repo.State()))
log.Info("arg", check.GetGoPath(), check.GetMasterVersion(), check.GoPrimitive)
if me.forge.FinalGoDepsCheckOk(check) {
log.Info("go.sum is perfect")
} else {
log.Info("go.sum check false")
}
// see if there is a new version
master := repo.Status.GetMasterVersion()
lastTag := repo.Status.LastTag()
log.Info("arg ", master, lastTag)
if master != lastTag {
os.Exit(-1)
}
}
} }
if findNext() { if findNext() {
log.Info("prepare release findNext() returned true") log.Info("prepare release findNext() returned true")

View File

@ -4,7 +4,6 @@ package main
import ( import (
"fmt" "fmt"
"os" "os"
"path/filepath"
"strings" "strings"
"time" "time"
@ -13,7 +12,6 @@ import (
"go.wit.com/lib/gadgets" "go.wit.com/lib/gadgets"
"go.wit.com/lib/gui/repolist" "go.wit.com/lib/gui/repolist"
"go.wit.com/lib/gui/shell"
) )
type releaseStruct struct { type releaseStruct struct {
@ -33,7 +31,6 @@ type releaseStruct struct {
goGetB *gui.Node goGetB *gui.Node
checkGoSumB *gui.Node checkGoSumB *gui.Node
checkDirtyB *gui.Node checkDirtyB *gui.Node
makeRedomodB *gui.Node
sendVersionB *gui.Node sendVersionB *gui.Node
checkSafeB *gui.Node checkSafeB *gui.Node
whitelist map[string]*repolist.RepoRow whitelist map[string]*repolist.RepoRow
@ -98,31 +95,13 @@ func createReleaseBox(box *gui.Node) {
me.autoWorkingPwd = gadgets.NewOneLiner(me.release.grid, "working directory (pwd)") me.autoWorkingPwd = gadgets.NewOneLiner(me.release.grid, "working directory (pwd)")
me.release.grid.NextRow() me.release.grid.NextRow()
me.userHomePwd = gadgets.NewOneLiner(me.release.grid, "user home") // me.userHomePwd = gadgets.NewOneLiner(me.release.grid, "user home")
me.release.grid.NextRow() // me.release.grid.NextRow()
me.goSrcPwd = gadgets.NewOneLiner(me.release.grid, "go src home") me.goSrcPwd = gadgets.NewOneLiner(me.release.grid, "go src home")
me.release.grid.NextRow() me.release.grid.NextRow()
homeDir, err := os.UserHomeDir() // me.userHomePwd.SetText(homeDir)
if err != nil { me.goSrcPwd.SetText(me.forge.GetGoSrc())
log.Warn("Error getting home directory:", err)
homeDir = "/home/autotypist"
}
me.userHomePwd.SetText(homeDir)
srcDir := filepath.Join(homeDir, "go/src")
me.goSrcPwd.SetText(srcDir)
testf := filepath.Join(srcDir, "go.wit.com/apps/guireleaser", "go.sum")
if !shell.Exists(testf) {
pb := me.forge.Repos.FindByGoPath("go.wit.com/apps/guireleaser")
if pb != nil {
pb.RedoGoMod()
}
if !shell.Exists(testf) {
log.Info("go.sum missing", testf)
panic("redo go.sum")
}
}
group := me.release.box.NewGroup("Run on Current Repo") group := me.release.box.NewGroup("Run on Current Repo")
grid := group.NewGrid("buildOptions", 0, 0) grid := group.NewGrid("buildOptions", 0, 0)

View File

@ -60,9 +60,6 @@ type autoType struct {
// The current working directory // The current working directory
autoWorkingPwd *gadgets.OneLiner autoWorkingPwd *gadgets.OneLiner
// shows what is being used as your home dir
userHomePwd *gadgets.OneLiner
// shows what directory being used as ~/go/src // shows what directory being used as ~/go/src
goSrcPwd *gadgets.OneLiner goSrcPwd *gadgets.OneLiner