logic is better

This commit is contained in:
Jeff Carr 2024-12-13 19:30:12 -06:00
parent 6f39827fb9
commit d1708d6a4b
Notes: Jeff Carr 2024-12-13 19:42:17 -06:00
// `autogen:go.mod`

module go.wit.com/apps/guireleaser

go 1.20

require (
	github.com/go-cmd/cmd v1.4.3
	go.wit.com/dev/alexflint/arg v1.5.5
	go.wit.com/gui v0.22.13
	go.wit.com/lib/debugger v0.22.5
	go.wit.com/lib/gadgets v0.22.5
	go.wit.com/lib/gui/logsettings v0.22.5
	go.wit.com/lib/gui/repolist v0.22.34
	go.wit.com/lib/gui/shell v0.22.16
	go.wit.com/lib/protobuf/forgepb v0.0.28
	go.wit.com/lib/protobuf/gitpb v0.0.28
	go.wit.com/log v0.22.9
)

require (
	github.com/destel/rill v0.6.0 // indirect
	github.com/google/uuid v1.6.0 // indirect
	go.wit.com/dev/alexflint/scalar v1.2.4 // indirect
	go.wit.com/lib/gui/repostatus v0.22.29 // indirect
	go.wit.com/lib/protobuf/virtbuf v0.2.16 // indirect
	go.wit.com/lib/protobuf/zoopb v0.0.19 // indirect
	go.wit.com/widget v1.1.27 // indirect
	google.golang.org/protobuf v1.35.2 // indirect
)

// `autogen:go.sum`

github.com/destel/rill v0.6.0 h1:8MQRzS6k0akKmwNZFahKIhG1dkBeNxMoWKSfOxkaJNw=
github.com/destel/rill v0.6.0/go.mod h1:srKuXzvGqINUEGYR5b/iwvW+L9/S35RxVHWGYbXNoO4=
github.com/go-cmd/cmd v1.4.3 h1:6y3G+3UqPerXvPcXvj+5QNPHT02BUw7p6PsqRxLNA7Y=
github.com/go-cmd/cmd v1.4.3/go.mod h1:u3hxg/ry+D5kwh8WvUkHLAMe2zQCaXd00t35WfQaOFk=
github.com/go-test/deep v1.1.0 h1:WOcxcdHcvdgThNXjw0t76K42FXTU7HpNQWHpA2HHNlg=
github.com/go-test/deep v1.1.0/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE=
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
go.wit.com/dev/alexflint/arg v1.5.5 h1:c4jgIb4OvHjnCMRNSjOa1sNLl6WDxV6tIkMVezR9hCk=
go.wit.com/dev/alexflint/arg v1.5.5/go.mod h1:nH3F6TJDaAUgnLkC0WgRN/H047YfN1TYKaWPYr6B8lo=
go.wit.com/dev/alexflint/scalar v1.2.4 h1:zmBeEkObwz1lcelwfGNYP2GS6SQ9e0tdv7JdHwMZEEk=
go.wit.com/dev/alexflint/scalar v1.2.4/go.mod h1:kCNO1Fo5LnnK6+qa+zYhP5fdgfC1C+vx1ti99Md+FAM=
go.wit.com/gui v0.22.13 h1:LJ5sloSN8Tc4VFIuV5GdOw/jc+OWD+zcToN7cwXsdRQ=
go.wit.com/gui v0.22.13/go.mod h1:fDDcr+MsTm53wix06uHXszpIE+6GZk0B6+3TWbQ7e8s=
go.wit.com/lib/debugger v0.22.5 h1:kq5XpoLkVYEQmW4r4y6GZPwO1iItDhlNOU2BT0IGc3I=
go.wit.com/lib/debugger v0.22.5/go.mod h1:+Q1NWiEIjoRzy7cN6c/D0/QcPgdIzYCSxbC8Gaht7mw=
go.wit.com/lib/gadgets v0.22.5 h1:sDBSIVb+MflU705ImwKFvP9hnnZdLVrwy+Xsgp/w7dw=
go.wit.com/lib/gadgets v0.22.5/go.mod h1:Hiap8lateez6bts/DFmu+HSX9y8rgCfmusnG/CiTuGM=
go.wit.com/lib/gui/logsettings v0.22.5 h1:rBv86U4xB5C/t+itqmH8CfXQ5cb+MaIc8E2Z8iCU2E4=
go.wit.com/lib/gui/logsettings v0.22.5/go.mod h1:6Rb0bMC56sdtUbJh/Z7DsRqNH4IHYm5MDbqA3f32KAY=
go.wit.com/lib/gui/repolist v0.22.34 h1:q9u2VVKeruYbvLwcPPyeQf8JhcL0/IhrfeptWkbW/sM=
go.wit.com/lib/gui/repolist v0.22.34/go.mod h1:TI6554E3XKsK+ES4LVzZUwAI8O0HFA6giu/SJyF7i3w=
go.wit.com/lib/gui/repostatus v0.22.29 h1:WKcGUBqGMnk/cjOV4G6aQGggT8oH4imRzgI601P3SIY=
go.wit.com/lib/gui/repostatus v0.22.29/go.mod h1:uw1PuOvoU053UZeWBzUW171qVFteZrfpNzsEuTJuP+4=
go.wit.com/lib/gui/shell v0.22.16 h1:MLCaJnxEjKWW275VeavKGvUo5G4AqkPOPG1mMt2SJps=
go.wit.com/lib/gui/shell v0.22.16/go.mod h1:nypmR50Bov++Ajjf2aC/RJ+4DWh2Xtm2ciaRm7pGY54=
go.wit.com/lib/protobuf/forgepb v0.0.28 h1:DQHbud2PRs880grg35DHS1+CwsylY/ERiZMO5Mo1jrs=
go.wit.com/lib/protobuf/forgepb v0.0.28/go.mod h1:RWMNF9b8vnMQNkA0/NzidkHQ61dmUJEBHrIt8P0h6DE=
go.wit.com/lib/protobuf/gitpb v0.0.28 h1:H07j5bHQ654Ojob/fVuCj5ShtH0TGKY632fyJ3muS5c=
go.wit.com/lib/protobuf/gitpb v0.0.28/go.mod h1:pBy6eSP/Q3eizNeYlKxxetowWPqOEKx+adTqkFWYS3U=
go.wit.com/lib/protobuf/virtbuf v0.2.16 h1:KWg23MXxo9ZNbnJNzuHf3SlG6wMvwuhDsYQ2x1oAgYU=
go.wit.com/lib/protobuf/virtbuf v0.2.16/go.mod h1:ec2g2Ld9ojFN7ws6Vx7kJ/F3WB9PhHulNoD9SWPfAQw=
go.wit.com/lib/protobuf/zoopb v0.0.19 h1:sC5l0gs20adoV/zws7VEYlPhmgB77TvyzSK2XY2r5NI=
go.wit.com/lib/protobuf/zoopb v0.0.19/go.mod h1:bdeHyuJI//suaWh97S0G2dBK46+e0gQk0u9nL3yfAcI=
go.wit.com/log v0.22.9 h1:aBM6SI2kxlJcBfS/osFTomJqNhO0hfEo1gk+LCqLk7Y=
go.wit.com/log v0.22.9/go.mod h1:4uNPFBqhsAh8zNF+zxVEmC3c/9AZ8JeTfUUvRpddvLQ=
go.wit.com/widget v1.1.27 h1:Yd+qp6GZVwLiTTepShXSeWSDqjaCxLyfhU0ch2FrPZ8=
go.wit.com/widget v1.1.27/go.mod h1:OXIdWk7GhVJRLnHTvf45LbPNXGYG/JjbkfnmXtkoiYE=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.35.2 h1:8Ar7bF+apOIoThw1EdZl0p1oWvMqTHmpA2fRTyZO8io=
google.golang.org/protobuf v1.35.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=

// `autogen:`
4 changed files with 22 additions and 63 deletions

View File

@ -3,7 +3,6 @@ package main
import (
"os"
"path/filepath"
"strings"
"time"
@ -227,18 +226,12 @@ func doPublishVersion() bool {
docmd := []string{"go", "get", "-v", gopath + "@" + me.release.version.String()}
log.Info("SHOULD RUN cmd HERE:", docmd)
testf := filepath.Join(me.forge.GetGoSrc(), "go.wit.com/apps/guireleaser", "go.sum")
if !shell.Exists(testf) {
pb := me.forge.Repos.FindByGoPath("go.wit.com/apps/guireleaser")
if pb != nil {
if err := pb.RunStrict([]string{"go-mod-clean"}); err != nil {
log.Info("go-mod-clean failed", err)
}
}
if !shell.Exists(testf) {
log.Info("go.sum missing", testf)
panic("redo go.sum")
}
if !me.startRepo.Exists("go.mod") {
log.Info("go.sum missing in", me.startRepo.GoPath)
log.Info("pick a different repo here")
log.Info("todo: error out earlier knowing this will upgrade")
log.Info("versions", me.startRepo.GetTargetVersion(), me.startRepo.GetMasterVersion())
panic("redo go.sum")
}
if me.current.Status.IsPrivate() {
// do not self update private repos
@ -248,23 +241,17 @@ func doPublishVersion() bool {
// try to pull from google
var result cmd.Status
if gopath == "go.wit.com/apps/guireleaser" {
if gopath == me.startRepo.GoPath {
log.Info("CAN NOT SELF UPDATE. cmd =", docmd)
log.Info("go get must be run from somewhere else other than guireleaser")
log.Info("chdir to autotypist if it exists")
if shell.Exists("/home/jcarr/go/src/go.wit.com/apps/autotypist") {
os.Chdir("/home/jcarr/go/src/go.wit.com/apps/autotypist")
} else {
log.Info("need to chdir somewhere with go.sum & go.mod")
return false
}
// result = shell.PathRun("/home/jcarr/go/src/go.wit.com/apps/autotypist", docmd)
} else {
// publish go.mod & go.sum for use with go
os.Unsetenv("GO111MODULE")
log.Info("TRYING TO SELF UPDATE HERE. cmd =", docmd)
result = me.release.guireleaser.Status.Run(docmd)
os.Exit(-1)
}
// publish go.mod & go.sum for use with go
os.Unsetenv("GO111MODULE")
log.Info("TRYING TO SELF UPDATE HERE. cmd =", docmd)
result = me.startRepo.Run(docmd)
if result.Error != nil {
log.Info("SELF UPDATE FAILED. error =", result.Error)
log.Info("SELF UPDATE FAILED. exit =", result.Exit)
@ -279,7 +266,7 @@ func doPublishVersion() bool {
log.Info("SELF UPDATE FAILED")
return false
}
log.Info("SELF UPDATE OK. out =", result.Stdout)
log.Info("SELF UPDATE OK. out =", strings.Join(result.Stdout, "\n"))
log.Info("SELF UPDATE WORKED")
return true
}

34
main.go
View File

@ -65,17 +65,6 @@ func main() {
os.Exit(0)
}
/*
// sanity check of things that might be around that mess
// up things later
// check to make sure we have a go.sum here
gosum := filepath.Join(homeDir, "go/src/go.wit.com/apps/guireleaser/go.sum")
if !shell.Exists(gosum) {
log.Info("go.sum must exist here")
os.Exit(0)
}
*/
log.Info("Creating the Release Window")
// initialize the repo list window
@ -122,28 +111,9 @@ func main() {
}
}
// the repo from the command line
// var myrepo *repolist.RepoRow
me.startRepo = me.forge.Repos.FindByGoPath("go.wit.com/apps/helloworld")
// find myself. the guireleaser directory is used as a working scratchpad
// for running go commands that can mess up the go.* files
loop = me.repos.View.ReposSortByName()
for loop.Scan() {
repo := loop.Repo()
if repo.GoPath() == "go.wit.com/apps/guireleaser" {
if me.release.guireleaser == nil {
me.release.guireleaser = repo
}
}
log.Info("repolist.ReposSortByName() found", repo.GoPath())
/*
if repo.GoPath() == myargs.Repo {
myrepo = repo
}
*/
}
if me.release.guireleaser == nil {
if me.startRepo == nil {
log.Info("Can not release if guireleaser was not found")
os.Exit(0)
}

View File

@ -34,10 +34,6 @@ type releaseStruct struct {
sendVersionB *gui.Node
checkSafeB *gui.Node
whitelist map[string]*repolist.RepoRow
// store myself here. use myself to
// do garbage go get tests and other potential junk
guireleaser *repolist.RepoRow
}
func (w *autoType) Disable() {

View File

@ -6,6 +6,7 @@ import (
"go.wit.com/lib/gadgets"
"go.wit.com/lib/gui/repolist"
"go.wit.com/lib/protobuf/forgepb"
"go.wit.com/lib/protobuf/gitpb"
)
var me *autoType
@ -20,6 +21,11 @@ type autoType struct {
reposgroup *gui.Node
current *repolist.RepoRow
// this is the repo we are starting in
// make sure it never changes so go.mod and go.sum are always there
// 'go get' is called from here
startRepo *gitpb.Repo
// guireleaser window
mainWindow *gui.Node
mainBox *gui.Node