Compare commits
70 Commits
Author | SHA1 | Date |
---|---|---|
|
dcac6d6608 | |
|
da0540d3a7 | |
|
bcaded6b37 | |
|
926a1ce33c | |
|
d31c80d780 | |
|
0e6cefb72e | |
|
5ceab01b0e | |
|
2d5a45476c | |
|
03daf07ec2 | |
|
dca25f2425 | |
|
756586e95e | |
|
bad8a5c628 | |
|
73cc9c0693 | |
|
63dc802ded | |
|
fd2254cd72 | |
|
d813ade5ab | |
|
7cf1758a36 | |
|
ad1144efe5 | |
|
fa876aa17d | |
|
131d6b4178 | |
|
c0d131a659 | |
|
e5c43347ea | |
|
515f862f19 | |
|
27b10fdc73 | |
|
09d595fd53 | |
|
d5626a5e23 | |
|
d8706ed738 | |
|
1528d8d507 | |
|
2f6b497b12 | |
|
c0b5f7da3a | |
|
8037a3cc01 | |
|
0cfaf29361 | |
|
0662c2e0cb | |
|
236a7cb5e8 | |
|
8d5d7ca85c | |
|
6add3f9982 | |
|
bfa63cac22 | |
|
392ea6e98e | |
|
0a1cb978e8 | |
|
3ff6dae849 | |
|
721ee08ad2 | |
|
38a0f70c78 | |
|
eb57f644f7 | |
|
93b659020b | |
|
a128a45ef9 | |
|
8efada2a54 | |
|
f70f3bfe1a | |
|
2f1d7ac1f2 | |
|
ffecf5ea0a | |
|
8f514d4268 | |
|
225cd84f68 | |
|
248642b681 | |
|
cfd6046978 | |
|
76c327b1f1 | |
|
447b4ebd3b | |
|
973032af1c | |
|
8d33a63e7e | |
|
8cc487393f | |
|
021c7774b2 | |
|
3ceb5d0bf5 | |
|
501241dbb6 | |
|
2ea06531dc | |
|
8d4687e2c1 | |
|
d81a1f6cb9 | |
|
ffb90cd28f | |
|
f690c1a8a3 | |
|
250742905f | |
|
9ee828cc3b | |
|
1d6c67b46c | |
|
2d118d3ae7 |
44
Makefile
44
Makefile
|
@ -55,15 +55,9 @@ curl-setBranchesToMasterB:
|
|||
findNext:
|
||||
curl --silent http://localhost:9419/findNext
|
||||
|
||||
fixNext:
|
||||
curl --silent http://localhost:9419/fixNext
|
||||
|
||||
showNext:
|
||||
curl --silent http://localhost:9419/showNext
|
||||
|
||||
testNext:
|
||||
curl --silent http://localhost:9419/testNext
|
||||
|
||||
doRelease:
|
||||
reset
|
||||
make showNext
|
||||
|
@ -92,6 +86,40 @@ list-release-notdone:
|
|||
curl --silent http://localhost:9419/releaseList?readonly=true
|
||||
|
||||
safe-build: install
|
||||
forge list --private
|
||||
# forge list --private
|
||||
wit-test install --verbose
|
||||
cd ~/go/src/go.wit.com/lib/xgb/ && GUIRELEASE_REASON="safe-build" guireleaser
|
||||
# cd ~/go/src/go.wit.com/lib/xgb/ && time GUIRELEASE_REASON="safe-build" guireleaser --gui gocui --gui-verbose --gui-file ../../toolkits/gocui/gocui.so >/tmp/forge.log 2>&1
|
||||
rm -f go.* ; git checkout go.mod ; cd ~/go/src/go.wit.com/lib/xgb/ && time GUIRELEASE_REASON="safe-build" guireleaser --gui andlabs
|
||||
|
||||
build-quick: install
|
||||
wit-test install --verbose
|
||||
# rm -f go.* ; git checkout go.mod ;cd ~/go/src/go.wit.com/lib/xgb/ && time GUIRELEASE_REASON="safe-build" guireleaser --gui andlabs quick
|
||||
sudo "wit update"
|
||||
|
||||
autocomplete:
|
||||
guireleaser --bash > ~/.local/share/bash-completion/completions/guireleaser
|
||||
|
||||
test-build-force:
|
||||
GUIRELEASE_REASON="safe-build" guireleaser --gui andlabs --force
|
||||
|
||||
# time GUIRELEASE_REASON="safe-build" make test-build
|
||||
test-build:
|
||||
wit-test install --verbose
|
||||
rm ~/go/bin/forged
|
||||
cd ~/go/src/go.wit.com/lib/xgb/ && rm -f go.*
|
||||
cd ~/go/src/go.wit.com/lib/xgb/ && git checkout go.mod
|
||||
cd ~/go/src/go.wit.com/lib/xgb/ && time guireleaser --gui andlabs
|
||||
cd ~/go/src/go.wit.com/apps/guireleaser
|
||||
wit-test debian --verbose
|
||||
do-aptly
|
||||
|
||||
# time GUIRELEASE_REASON="safe-build" make test-build-quick
|
||||
test-build-quick:
|
||||
wit-test install --verbose
|
||||
rm ~/go/bin/forged
|
||||
cd ~/go/src/go.wit.com/lib/xgb/ && rm -f go.*
|
||||
cd ~/go/src/go.wit.com/lib/xgb/ && git checkout go.mod
|
||||
cd ~/go/src/go.wit.com/lib/xgb/ && time guireleaser --gui andlabs quick
|
||||
cd ~/go/src/go.wit.com/apps/guireleaser
|
||||
wit-test debian --verbose
|
||||
do-aptly
|
||||
|
|
8
TODO
8
TODO
|
@ -2,13 +2,7 @@ notes on what to fix next
|
|||
|
||||
go-args make patches for alexflint
|
||||
|
||||
forge checkout jcarr (alias username to 'user')
|
||||
forge verify devel branches
|
||||
|
||||
fix going2go build
|
||||
fix fyne build
|
||||
|
||||
go-mod-clean --restore *.pb.go files
|
||||
go-mod-clean set ctime on files
|
||||
go-mod-clean fix --purge to be used more often. put --purge in 'make clean' ?
|
||||
|
||||
guireleaser change "title small" to the package being updated"
|
||||
|
|
48
argv.go
48
argv.go
|
@ -1,5 +1,11 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/user"
|
||||
)
|
||||
|
||||
/*
|
||||
this parses the command line arguements
|
||||
|
||||
|
@ -9,11 +15,12 @@ package main
|
|||
type args struct {
|
||||
Quick *QuickCmd `arg:"subcommand:quick" help:"only do repos with patches"`
|
||||
DryRun bool `arg:"--dry-run,env:DRYRUN" help:"don't actually do the release"`
|
||||
// Fix bool `arg:"--fix" help:"run fixGoMod() on startup"`
|
||||
Minor bool `arg:"--minor" help:"increment minor verion numbers"`
|
||||
Protobuf bool `arg:"--protobuf" help:"increment protobuf repos"`
|
||||
Verbose bool `arg:"--verbose" help:"talk alot"`
|
||||
Full bool `arg:"--full" help:"build every package"`
|
||||
Reason string `arg:"--reason" help:"tag message"`
|
||||
// DumpVersions bool `arg:"--dump-versions" help:"dump the versions file for go.wit.com"`
|
||||
Force bool `arg:"--force" help:"try harder than normal"`
|
||||
Port int `arg:"--port" default:"9419" help:"do fun stuff with curl"`
|
||||
Bash bool `arg:"--bash" help:"generate bash completion"`
|
||||
BashAuto []string `arg:"--auto-complete" help:"does the actual autocompletion"`
|
||||
|
@ -22,6 +29,7 @@ type args struct {
|
|||
type QuickCmd struct {
|
||||
List *EmptyCmd `arg:"subcommand:list" help:"list available patches"`
|
||||
Show *EmptyCmd `arg:"subcommand:show" help:"show a specific patch"`
|
||||
NoLibs *EmptyCmd `arg:"subcommand:show" help:"skip libraries that aren't changed"`
|
||||
}
|
||||
|
||||
type EmptyCmd struct {
|
||||
|
@ -39,3 +47,39 @@ the repositories in the go.sum file using git clone`
|
|||
func (args) Version() string {
|
||||
return "guireleaser " + VERSION
|
||||
}
|
||||
|
||||
/*
|
||||
handles shell autocomplete
|
||||
*/
|
||||
|
||||
func (a args) DoAutoComplete(argv []string) {
|
||||
switch argv[0] {
|
||||
case "checkout":
|
||||
usr, _ := user.Current()
|
||||
fmt.Println("user devel master " + usr.Username)
|
||||
case "commit":
|
||||
fmt.Println("--all")
|
||||
case "config":
|
||||
fmt.Println("add fix list delete")
|
||||
case "list":
|
||||
fmt.Println("--all --mine --favorites --private")
|
||||
case "pull":
|
||||
fmt.Println("--all --mine --favorites --private")
|
||||
case "patch":
|
||||
fmt.Println("--list --submit --show")
|
||||
case "dirty":
|
||||
fmt.Println("--show-files")
|
||||
case "user":
|
||||
fmt.Println("--force")
|
||||
case "devel":
|
||||
fmt.Println("--force")
|
||||
case "master":
|
||||
fmt.Println("--force")
|
||||
default:
|
||||
if argv[0] == ARGNAME {
|
||||
// list the subcommands here
|
||||
fmt.Println("--bash quick")
|
||||
}
|
||||
}
|
||||
os.Exit(0)
|
||||
}
|
||||
|
|
|
@ -1,97 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/user"
|
||||
)
|
||||
|
||||
/*
|
||||
handles shell autocomplete
|
||||
*/
|
||||
|
||||
// used for shell auto completion
|
||||
// var ARGNAME string = "forge" // todo: get this from $0 ?
|
||||
|
||||
func (args) doBashAuto() {
|
||||
argv.doBashHelp()
|
||||
switch argv.BashAuto[0] {
|
||||
case "checkout":
|
||||
usr, _ := user.Current()
|
||||
fmt.Println("user devel master " + usr.Username)
|
||||
case "commit":
|
||||
fmt.Println("--all")
|
||||
case "config":
|
||||
fmt.Println("add fix list delete")
|
||||
case "list":
|
||||
fmt.Println("--all --mine --favorites --private")
|
||||
case "pull":
|
||||
fmt.Println("--all --mine --favorites --private")
|
||||
case "patch":
|
||||
fmt.Println("--list --submit --show")
|
||||
case "dirty":
|
||||
fmt.Println("--show-files")
|
||||
case "user":
|
||||
fmt.Println("--force")
|
||||
case "devel":
|
||||
fmt.Println("--force")
|
||||
case "master":
|
||||
fmt.Println("--force")
|
||||
default:
|
||||
if argv.BashAuto[0] == ARGNAME {
|
||||
// list the subcommands here
|
||||
fmt.Println("--bash quick")
|
||||
}
|
||||
}
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
// prints help to STDERR // TODO: move everything below this to go-args
|
||||
func (args) doBashHelp() {
|
||||
if argv.BashAuto[1] != "''" {
|
||||
// if this is not blank, then the user has typed something
|
||||
return
|
||||
}
|
||||
if argv.BashAuto[0] != ARGNAME {
|
||||
// if this is not the name of the command, the user already started doing something
|
||||
return
|
||||
}
|
||||
if argv.BashAuto[0] == ARGNAME {
|
||||
me.pp.WriteHelp(os.Stderr)
|
||||
return
|
||||
}
|
||||
fmt.Fprintln(os.Stderr, "")
|
||||
fmt.Fprintln(os.Stderr, "hello world")
|
||||
fmt.Fprintln(os.Stderr, "")
|
||||
}
|
||||
|
||||
// complete -F forge --bash forge
|
||||
func (args) doBash() {
|
||||
fmt.Println("# add this in your bashrc:")
|
||||
fmt.Println("")
|
||||
fmt.Println("# todo: add this to go-arg as a 'hidden' go-arg option --bash")
|
||||
fmt.Println("#")
|
||||
fmt.Println("# todo: make this output work/parse with:")
|
||||
fmt.Println("# complete -C " + ARGNAME + " --bash go")
|
||||
fmt.Println("")
|
||||
fmt.Println("_" + ARGNAME + "_complete()")
|
||||
fmt.Println("{")
|
||||
fmt.Println(" # sets local to this func vars")
|
||||
fmt.Println(" local cur prev all")
|
||||
fmt.Println(" cur=${COMP_WORDS[COMP_CWORD]}")
|
||||
fmt.Println(" prev=${COMP_WORDS[COMP_CWORD-1]}")
|
||||
fmt.Println(" all=${COMP_WORDS[@]}")
|
||||
fmt.Println("")
|
||||
fmt.Println(" # this is where we generate the go-arg output")
|
||||
fmt.Println(" GOARGS=$(" + ARGNAME + " --auto-complete $prev \\'$cur\\' $all)")
|
||||
fmt.Println("")
|
||||
fmt.Println(" # this compares the command line input from the user")
|
||||
fmt.Println(" # to whatever strings we output")
|
||||
fmt.Println(" COMPREPLY=( $(compgen -W \"$GOARGS\" -- $cur) ) # THIS WORKS")
|
||||
fmt.Println(" return 0")
|
||||
fmt.Println("}")
|
||||
fmt.Println("complete -F _" + ARGNAME + "_complete " + ARGNAME)
|
||||
fmt.Println("")
|
||||
fmt.Println("# copy and paste the above into your bash shell should work")
|
||||
os.Exit(0)
|
||||
}
|
144
doRelease.go
144
doRelease.go
|
@ -12,23 +12,24 @@ import (
|
|||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
func doRelease() bool {
|
||||
func doRelease() error {
|
||||
check := me.current
|
||||
log.Info("doRelease() on", me.current.GetGoPath())
|
||||
if !findOk {
|
||||
log.Info("doRelease() immediately end something went wrong last time. findOk == false")
|
||||
return false
|
||||
return fmt.Errorf("findOK = false %s", check.GetGoPath())
|
||||
}
|
||||
// double check release version logic
|
||||
if me.release.releaseVersionB.String() != "release version "+me.release.version.String() {
|
||||
log.Warn("something went wrong with the release.version:", me.release.version.String())
|
||||
return false
|
||||
return fmt.Errorf("GUI lied %s", check.GetGoPath())
|
||||
}
|
||||
|
||||
if strings.HasPrefix(me.release.version.String(), "v") {
|
||||
log.Warn("everything is ok. version starts with v.", me.release.version.String())
|
||||
} else {
|
||||
log.Warn("version does not start with v.", me.release.version.String())
|
||||
return false
|
||||
return fmt.Errorf("release does not start with a v %s", check.GetGoPath())
|
||||
}
|
||||
|
||||
if shell.Exists("go.mod") {
|
||||
|
@ -36,21 +37,16 @@ func doRelease() bool {
|
|||
} else {
|
||||
pwd, _ := os.Getwd()
|
||||
log.Info("go.mod missing in working dir", pwd)
|
||||
return false
|
||||
return fmt.Errorf("go.mod missing %s", check.GetGoPath())
|
||||
}
|
||||
|
||||
curName := me.current.GetCurrentBranchName()
|
||||
mName := me.current.GetMasterBranchName()
|
||||
if curName != mName {
|
||||
log.Info("\trepo is not working from main branch", curName, "!=", mName)
|
||||
return false
|
||||
return fmt.Errorf("not on main branch %s", check.GetGoPath())
|
||||
}
|
||||
|
||||
check := me.forge.FindByGoPath(me.current.GetGoPath())
|
||||
if check == nil {
|
||||
log.Info("boo, you didn't git clone", me.current.GetGoPath())
|
||||
return false
|
||||
}
|
||||
if alreadyDone(check) {
|
||||
// means it was already published
|
||||
// protects against logic errors that might result
|
||||
|
@ -58,15 +54,37 @@ func doRelease() bool {
|
|||
log.Info("doRelease() WARNING. should have never gotten here. return true. already done", check.GetGoPath())
|
||||
log.Info("doRelease() WARNING. should have never gotten here. return true. already done", check.GetGoPath())
|
||||
log.Info("doRelease() WARNING. should have never gotten here. return true. already done", check.GetGoPath())
|
||||
check.Reload()
|
||||
log.Sleep(1)
|
||||
return true
|
||||
check.ReloadCheck()
|
||||
return fmt.Errorf("already released %s", check.GetGoPath())
|
||||
}
|
||||
|
||||
// check if the git tag already exists somehow
|
||||
testtag := me.release.version.String()
|
||||
if check.LocalTagExists(testtag) {
|
||||
log.Info("TAG ALREADY EXISTS", testtag)
|
||||
return log.Errorf("%s TAG ALREADY EXISTS %s", check.FullPath, testtag)
|
||||
} else {
|
||||
log.Info("TAG IS NEW", testtag)
|
||||
}
|
||||
|
||||
if me.forge.Config.IsPrivate(me.current.GetGoPath()) {
|
||||
// do not self update private repos
|
||||
log.Info("This is a private repo.")
|
||||
var retag [][]string
|
||||
retag = append(retag, []string{"git", "tag", "-m", me.releaseReasonS, me.release.version.String()})
|
||||
retag = append(retag, []string{"git", "push", "origin", me.release.version.String()})
|
||||
if !me.current.RunAll(retag) {
|
||||
log.Info("retag failed")
|
||||
findOk = false
|
||||
return fmt.Errorf("RETAG FAILED %s", check.GetGoPath())
|
||||
}
|
||||
return skipToNext()
|
||||
}
|
||||
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())
|
||||
badExit(errors.New(msg))
|
||||
return false
|
||||
return fmt.Errorf("FinalGoDeps %s err %v", check.GetGoPath(), err)
|
||||
}
|
||||
if check.GetGoPath() == me.startRepo.GetGoPath() {
|
||||
log.Info("CAN NOT SELF UPDATE.", check.GetGoPath(), "is the same as os.Getwd()")
|
||||
|
@ -91,6 +109,23 @@ func doRelease() bool {
|
|||
badExit(errors.New(msg))
|
||||
}
|
||||
|
||||
// this is the final check. even here, just to be a total asshole
|
||||
// I rerun go mod init and go mod tidy
|
||||
// the re-parse all the results
|
||||
// this is the last and final check.
|
||||
// believe it or not, I've seen this fail. It's not worth being careful here
|
||||
// or liberal about it. if it doesn't work, yep, you are stuck here you bastard
|
||||
// (bastard being me. I designed this to be so annoying that if it makes it
|
||||
// past this point it always works. that is the whole point of this code. NEVER
|
||||
// EVER FAIL PAST THIS POINT
|
||||
// )
|
||||
// so let's do it: let's run go-mod-clean strict
|
||||
// then reparse everything
|
||||
_, err := check.RunVerboseOnError([]string{"go-mod-clean", "strict"})
|
||||
if err != nil {
|
||||
badExit(err)
|
||||
}
|
||||
|
||||
var all [][]string
|
||||
var autogen []string
|
||||
all = append(all, []string{"git", "add", "-f", "go.mod"})
|
||||
|
@ -135,7 +170,7 @@ func doRelease() bool {
|
|||
if !me.current.RunAll(all) {
|
||||
log.Info("failed to make new release", me.release.version.String())
|
||||
findOk = false
|
||||
return false
|
||||
return fmt.Errorf("setting findOK = false %s", check.GetGoPath())
|
||||
}
|
||||
log.Info("RELEASE OK")
|
||||
|
||||
|
@ -144,9 +179,9 @@ func doRelease() bool {
|
|||
time.Sleep(3 * time.Second)
|
||||
// this can fail to update, try it again after sleep(3s)
|
||||
if !doPublishVersion() {
|
||||
log.Info("PUBLISH FAILED")
|
||||
log.Info("PUBLISH FAILED gopath=%s", check.GetGoPath())
|
||||
findOk = false
|
||||
return false
|
||||
return fmt.Errorf("PUBLISH FAILED gopath=%s", check.GetGoPath())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -158,7 +193,7 @@ func doRelease() bool {
|
|||
if !me.current.RevertMasterToDevel() {
|
||||
log.Info("Revert Failed")
|
||||
findOk = false
|
||||
return false
|
||||
return fmt.Errorf("REVERT FAILED %s", check.GetGoPath())
|
||||
}
|
||||
|
||||
// update tag
|
||||
|
@ -168,79 +203,14 @@ func doRelease() bool {
|
|||
retag = append(retag, []string{"git", "tag", "-m", me.releaseReasonS, me.release.version.String()})
|
||||
retag = append(retag, []string{"git", "push", "origin", me.release.version.String()})
|
||||
|
||||
if err := check.AutogenRestore(cname); err != nil {
|
||||
log.Info("AutogenRestore() failed", err)
|
||||
} else {
|
||||
cmd := []string{"git", "push", "origin", "refs/notes/*:refs/notes/*"}
|
||||
check.Run(cmd)
|
||||
}
|
||||
|
||||
if !me.current.RunAll(retag) {
|
||||
log.Info("retag failed")
|
||||
findOk = false
|
||||
return false
|
||||
return fmt.Errorf("RETAG FAILED %s", check.GetGoPath())
|
||||
}
|
||||
log.Info("EVERYTHING OK. RERELEASED", me.current.GetGoPath())
|
||||
|
||||
// save autogen files under the tag version (for example: "v0.2.3")
|
||||
newtag := me.release.version.String()
|
||||
if err := check.AutogenSave(autogen, newtag, true); err != nil {
|
||||
log.Info("AutogenSave() error", err)
|
||||
msg := fmt.Sprint("AutogenSave() error", err)
|
||||
badExit(errors.New(msg))
|
||||
}
|
||||
|
||||
printDone()
|
||||
log.Info("sleep 2, then Reload()", check.GetGoPath())
|
||||
time.Sleep(2 * time.Second) // notsure
|
||||
check.Reload()
|
||||
|
||||
// run this each time something gets published successfully
|
||||
rePrepareRelease()
|
||||
|
||||
// attempt to find another repo to release
|
||||
if !doReleaseFindNext() {
|
||||
log.Info("doReleaseFindNext() could not find a new", findCounter)
|
||||
log.Info("THIS PROBABLY MEANS THAT ACTUALLY WE ARE TOTALLY DONE?", findCounter)
|
||||
count := me.forge.PrintReleaseReport(me.found)
|
||||
log.Info("count =", count)
|
||||
os.Setenv("FindNextDone", "true")
|
||||
printDone()
|
||||
return false
|
||||
}
|
||||
log.Info("GOOD TO RUN ANOTHER DAY ON:", me.current.GetGoPath())
|
||||
printDone()
|
||||
return true
|
||||
}
|
||||
|
||||
// try to figure out if there is another package to update
|
||||
// returns true if it finds something
|
||||
func doReleaseFindNext() bool {
|
||||
// scan for new repo
|
||||
if findNext() {
|
||||
log.Info("findNext() found something")
|
||||
} else {
|
||||
// this means findNext() didn't find anything but there are
|
||||
// still packages to release. start trying to fix the go.sum files
|
||||
if findCounter != 0 {
|
||||
findFix = true
|
||||
}
|
||||
log.Info("findNext() could not find anything")
|
||||
return false
|
||||
}
|
||||
check := me.forge.FindByGoPath(me.current.GetGoPath())
|
||||
if check == nil {
|
||||
log.Info("boo, you didn't git clone", me.current.GetGoPath())
|
||||
return false
|
||||
}
|
||||
if findFix {
|
||||
fixGodeps(check)
|
||||
}
|
||||
if me.forge.FinalGoDepsCheckOk(check, false) {
|
||||
// the go.sum file is ok to release
|
||||
return true
|
||||
}
|
||||
return false
|
||||
return nil
|
||||
}
|
||||
|
||||
// this pulls the new tag from the golang package repository
|
||||
|
|
5
exit.go
5
exit.go
|
@ -8,11 +8,12 @@ import (
|
|||
|
||||
func okExit(thing string) {
|
||||
log.Info(thing, "ok")
|
||||
// log.Info("Finished go-clean on", check.GetGoPath(), "ok")
|
||||
// log.Info("Finished go-clean on", check.GetNamespace(), "ok")
|
||||
me.forge.Exit()
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
func badExit(err error) {
|
||||
log.Info("forge failed: ", err, me.forge.GetGoSrc())
|
||||
log.Info("forge failed: ", err, me.forge.Config.ReposDir)
|
||||
os.Exit(-1)
|
||||
}
|
||||
|
|
277
findNext.go
277
findNext.go
|
@ -1,4 +1,3 @@
|
|||
// This is a simple example
|
||||
package main
|
||||
|
||||
import (
|
||||
|
@ -9,7 +8,6 @@ import (
|
|||
|
||||
"go.wit.com/log"
|
||||
|
||||
"go.wit.com/lib/gui/shell"
|
||||
"go.wit.com/lib/protobuf/gitpb"
|
||||
)
|
||||
|
||||
|
@ -17,78 +15,27 @@ var findCounter int
|
|||
var findFix bool = false
|
||||
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 {
|
||||
if repo.GoDeps == nil {
|
||||
return fmt.Errorf("%s has GoDeps == nil", repo.GetGoPath())
|
||||
return fmt.Errorf("%s has GoDeps == nil", repo.GetNamespace())
|
||||
}
|
||||
all := repo.GoDeps.All()
|
||||
for all.Scan() {
|
||||
dep := all.Next()
|
||||
// log.Info(repo.GetGoPath(), dep.GoPath, dep.Version)
|
||||
for dep := range repo.GoDeps.IterAll() {
|
||||
// log.Info(repo.GetNamespace(), 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 dep == nil", repo.GetGoPath(), dep.GoPath)
|
||||
return fmt.Errorf("%s has dep == nil", repo.GetNamespace(), dep.GoPath)
|
||||
}
|
||||
|
||||
// loop through all the repos that need to be published with new go versions
|
||||
all := me.found.SortByFullPath()
|
||||
for all.Scan() {
|
||||
check := all.Next()
|
||||
if found.GetGoPath() == check.GetGoPath() {
|
||||
|
||||
if found.GetNamespace() == check.GetNamespace() {
|
||||
// this package is waiting on other packages to publish
|
||||
return fmt.Errorf("%s is waiting on %s", repo.GetGoPath(), found.GetGoPath())
|
||||
return fmt.Errorf("%s is waiting on %s", repo.GetNamespace(), found.GetNamespace())
|
||||
}
|
||||
}
|
||||
// found package isn't being published. is the version correct?
|
||||
|
@ -97,7 +44,7 @@ func checkDeps(repo *gitpb.Repo) error {
|
|||
if found.GetLastTag() == dep.Version {
|
||||
// everything is normal
|
||||
} else {
|
||||
return fmt.Errorf("%s version mismatch on %s (%s vs %s)", repo.GetGoPath(), found.GetGoPath(), found.GetLastTag(), dep.Version)
|
||||
return fmt.Errorf("%s version mismatch on %s (%s vs %s)", repo.GetNamespace(), found.GetNamespace(), found.GetLastTag(), dep.Version)
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
@ -113,156 +60,108 @@ func findNext() bool {
|
|||
all := me.found.SortByFullPath()
|
||||
for all.Scan() {
|
||||
check := all.Next()
|
||||
if err := checkDeps(check); err != nil {
|
||||
log.Info("\t", check.GetGoPath(), err)
|
||||
continue
|
||||
} else {
|
||||
log.Info("Might be ok?", check.GetGoPath())
|
||||
}
|
||||
if check.GetMasterBranchName() != check.GetCurrentBranchName() {
|
||||
log.Info("YOU MUST BE ON THE MASTER BRANCHES")
|
||||
os.Exit(-1)
|
||||
log.Info("YOU MUST BE ON THE MASTER BRANCH", check.GetNamespace())
|
||||
continue
|
||||
}
|
||||
_, err := check.RunVerboseOnError([]string{"go-mod-clean", "--strict"})
|
||||
if err != nil {
|
||||
os.Exit(-1)
|
||||
}
|
||||
|
||||
if check.IsDirty() {
|
||||
log.Info("findNext() skipping dirty")
|
||||
log.Info("CAN NOT RELEASE DIRTY REPO", check.GetNamespace())
|
||||
continue
|
||||
}
|
||||
/*
|
||||
if findFix {
|
||||
log.Info("findFix is true. running fixGoDeps()")
|
||||
if fixGodeps(check) {
|
||||
log.Info("fixGoDeps() returned true")
|
||||
} else {
|
||||
log.Info("fixGoDeps() returned false")
|
||||
if alreadyDone(check) {
|
||||
log.Info("findNext() alreadyDone. WHY IS THIS STILL CHECKING?", check.GetNamespace())
|
||||
continue
|
||||
}
|
||||
log.Info("CHECKING START:", check.GetNamespace())
|
||||
|
||||
}
|
||||
*/
|
||||
findCounter += 1
|
||||
if !check.ParseGoSum() {
|
||||
log.Info("ParseGoSum() failed")
|
||||
log.Info("ParseGoSum() failed")
|
||||
log.Info("ParseGoSum() failed")
|
||||
continue
|
||||
}
|
||||
if me.forge.FinalGoDepsCheckOk(check, false) {
|
||||
if me.forge.Config.IsPrivate(check.GetNamespace()) {
|
||||
log.Info("GOOD TO GO ON PRIVATE REPO", check.GetNamespace())
|
||||
setCurrentRepo(check, "should be good to release", "pretty sure")
|
||||
return true
|
||||
}
|
||||
|
||||
godepsNew, err := check.GoSumFromRepo()
|
||||
if err != nil {
|
||||
log.Info("CHECKING go deps from repo failed", err)
|
||||
continue
|
||||
|
||||
}
|
||||
if godepsNew == nil {
|
||||
// don't check godepsNew, but check to make sure go mod tidy actually ran without error
|
||||
os.Unsetenv("GO111MODULE")
|
||||
cmd := []string{"go", "mod", "tidy"}
|
||||
err := check.RunVerbose(cmd)
|
||||
if err != nil {
|
||||
log.Info("go mod tidy failed. this go package needs to be examined by hand as it doesn't appear to be primitive")
|
||||
os.Exit(-1)
|
||||
}
|
||||
// if godepsNew == nil, then this go package is a primitive and there is no go.sum file
|
||||
} else {
|
||||
log.Info("FinalGoDepsCheckOk() failed")
|
||||
log.Info("FinalGoDepsCheckOk() failed")
|
||||
log.Info("FinalGoDepsCheckOk() failed")
|
||||
if err := testGoDepsCheckOk(godepsNew, argv.Verbose); err != nil {
|
||||
log.Info("CHECKING current repo deps failed", err)
|
||||
continue
|
||||
}
|
||||
log.Info("findNext() got to the end. repo", check.GetGoPath(), "did not work. trying to find a new one now")
|
||||
}
|
||||
|
||||
if err := me.forge.FinalGoDepsCheckOk(check, argv.Verbose); err != nil {
|
||||
// if err := me.forge.FinalGoDepsCheckOk(check, false); err != nil {
|
||||
log.Info("FinalGoDepsCheckOk() repo=", check.GetNamespace(), "err:", err)
|
||||
log.Info("CHECKING END:", check.GetNamespace())
|
||||
log.Info("")
|
||||
continue
|
||||
}
|
||||
log.Info("GOOD TO GO ON", check.GetNamespace())
|
||||
setCurrentRepo(check, "should be good to release", "pretty sure")
|
||||
return true
|
||||
}
|
||||
|
||||
if findCounter == 0 {
|
||||
log.Info("NOTHING TO UPDATE. findCounter =", findCounter)
|
||||
log.Info("NOTHING TO UPDATE. findCounter =", findCounter, "found len =", me.found.Len())
|
||||
if me.found.Len() == 0 {
|
||||
printDone()
|
||||
okExit("")
|
||||
}
|
||||
} else {
|
||||
findFix = true
|
||||
log.Info("me.current is nil findCounter =", findCounter, "so set findFix =", findFix)
|
||||
}
|
||||
log.Info("tried to findNext() but not sure what to do next counter =", findCounter, "findFix =", findFix)
|
||||
setCurrentRepo(nil, "findNext found nothing", "crap")
|
||||
me.release.status.SetText("ALL DONE?")
|
||||
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
|
||||
func fixGodeps(check *gitpb.Repo) bool {
|
||||
log.Info("fixGoDeps() START", check.GetGoPath())
|
||||
log.Info("fixGoDeps() START", check.GetGoPath())
|
||||
log.Info("fixGoDeps() START", check.GetGoPath())
|
||||
var good bool = true
|
||||
if !runGoClean(check, "--strict") {
|
||||
log.Info("fixGoDeps() runGoClean() strict failed", check.GetGoPath())
|
||||
log.Info("fixGoDeps() runGoClean() strict failed", check.GetGoPath())
|
||||
log.Info("fixGoDeps() runGoClean() strict failed", check.GetGoPath())
|
||||
return false
|
||||
}
|
||||
// skip primative ones
|
||||
if check.GetGoPrimitive() {
|
||||
if check.Exists("go.sum") {
|
||||
log.Info("fixGoDeps() has go.sum but says it is primitive", check.GetGoPath())
|
||||
return false
|
||||
}
|
||||
log.Info("fixGoDeps() skipping primitive", check.GetGoPath())
|
||||
return true
|
||||
}
|
||||
log.Printf("current repo %s go dependancy count: %d\n", check.GetGoPath(), check.GoDepsLen())
|
||||
log.Printf("current repo %s go dependancy count: %d\n", check.GetGoPath(), check.GoDepsLen())
|
||||
log.Printf("current repo %s go dependancy count: %d\n", check.GetGoPath(), check.GoDepsLen())
|
||||
deps := check.GoDeps.SortByGoPath()
|
||||
for deps.Scan() {
|
||||
depRepo := deps.Next()
|
||||
// log.Info("found dep", depRepo.GetGoPath())
|
||||
if me.forge.Config.IsReadOnly(depRepo.GetGoPath()) {
|
||||
log.Info("IsReadOnly = true", depRepo.GetGoPath())
|
||||
continue
|
||||
} else {
|
||||
// log.Info("IsReadOnly = false", depRepo.GetGoPath())
|
||||
}
|
||||
found := me.forge.FindByGoPath(depRepo.GetGoPath())
|
||||
if found == nil {
|
||||
log.Info("not found:", depRepo.GetGoPath())
|
||||
continue
|
||||
}
|
||||
log.Printf("%-48s dep ver=%10s repo ver=%10s target ver=%10s\n", found.GetGoPath(), depRepo.GetVersion(), found.GetMasterVersion(), found.GetTargetVersion())
|
||||
if depRepo.GetVersion() != found.GetMasterVersion() {
|
||||
log.Printf("%-48s %10s (gitpb depRepo)\n", depRepo.GetGoPath(), depRepo.GetVersion())
|
||||
log.Printf("%-48s %10s (gitpb found)\n", found.GetGoPath(), found.GetMasterVersion())
|
||||
cmd := []string{"go", "get", depRepo.GetGoPath() + "@latest"}
|
||||
check.RunVerbose(cmd)
|
||||
}
|
||||
}
|
||||
return good
|
||||
}
|
||||
|
||||
func setCurrentRepo(check *gitpb.Repo, s string, note string) bool {
|
||||
me.release.repo.SetText(check.GetGoPath())
|
||||
me.release.status.SetText(s)
|
||||
me.release.notes.SetText(note)
|
||||
me.current = check
|
||||
if check == nil {
|
||||
me.release.repo.SetText("")
|
||||
me.release.version.SetText("")
|
||||
me.release.releaseVersionB.SetText("nope")
|
||||
me.release.version.SetText("badver")
|
||||
} else {
|
||||
me.release.repo.SetText(check.GetNamespace())
|
||||
me.release.version.SetText(check.GetTargetVersion())
|
||||
me.release.releaseVersionB.SetText("release version " + check.GetTargetVersion())
|
||||
me.release.openrepo.Enable()
|
||||
|
||||
me.release.version.SetText(check.GetTargetVersion())
|
||||
}
|
||||
me.release.status.SetText(s)
|
||||
me.release.notes.SetText(note)
|
||||
// me.release.openrepo.Enable()
|
||||
return true
|
||||
}
|
||||
|
||||
func testGoDepsCheckOk(godeps *gitpb.GoDeps, verbose bool) error {
|
||||
if godeps == nil {
|
||||
return errors.New("testGoDepsCheckOk() godeps == nil")
|
||||
}
|
||||
all := godeps.SortByGoPath()
|
||||
for all.Scan() {
|
||||
depRepo := all.Next()
|
||||
fullpath := filepath.Join(me.forge.Config.ReposDir, depRepo.GoPath)
|
||||
found := me.found.FindByFullPath(fullpath)
|
||||
if found == nil {
|
||||
continue
|
||||
}
|
||||
return fmt.Errorf("dep is being upgraded %s", depRepo.GoPath)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ import (
|
|||
"go.wit.com/gui"
|
||||
"go.wit.com/lib/debugger"
|
||||
"go.wit.com/lib/gui/logsettings"
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
func globalDisplayOptions(box *gui.Node) {
|
||||
|
@ -12,8 +11,8 @@ func globalDisplayOptions(box *gui.Node) {
|
|||
|
||||
group1 := vbox.NewGroup("Global Display Options")
|
||||
|
||||
/*
|
||||
hidegrid := group1.NewGrid("hidecfg", 0, 0)
|
||||
|
||||
hidegrid.NewButton("Show Repository Window", func() {
|
||||
if me.repos.Hidden() {
|
||||
me.repos.Show()
|
||||
|
@ -23,12 +22,13 @@ func globalDisplayOptions(box *gui.Node) {
|
|||
log.Info("showing reposwin")
|
||||
})
|
||||
hidegrid.NextRow()
|
||||
*/
|
||||
|
||||
group1 = vbox.NewGroup("prep for release")
|
||||
grid := group1.RawGrid()
|
||||
|
||||
grid.NewButton("make prepare-release", func() {
|
||||
makePrepareRelease()
|
||||
rePrepareRelease()
|
||||
})
|
||||
grid.NextRow()
|
||||
|
||||
|
|
17
http.go
17
http.go
|
@ -46,7 +46,7 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
|
|||
log.Info("")
|
||||
case "/doRelease":
|
||||
buttonDisable()
|
||||
if doRelease() {
|
||||
if err := doRelease(); err == nil {
|
||||
buttonEnable()
|
||||
log.Info("doRelease() worked")
|
||||
} else {
|
||||
|
@ -72,8 +72,6 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
// log.Info(me.current.StandardHeader())
|
||||
log.Info(me.forge.StandardReleaseHeader(me.current, "todoing"))
|
||||
case "/rescanAll":
|
||||
me.repos.View.ScanRepositories()
|
||||
case "/setCurrentRepo":
|
||||
log.Info("repo: " + repoName)
|
||||
log.Info("version: " + version)
|
||||
|
@ -87,16 +85,6 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
setCurrentRepo(repo, "HTTP", "doRelease() ?")
|
||||
return
|
||||
case "/fixNext":
|
||||
check := me.forge.FindByGoPath(me.current.GetGoPath())
|
||||
if check == nil {
|
||||
log.Info("boo, you didn't git clone", me.current.GetGoPath())
|
||||
return
|
||||
}
|
||||
// destroy and recreate the go.sum
|
||||
fixGodeps(check)
|
||||
findOk = true
|
||||
return
|
||||
case "/showNext":
|
||||
check := me.forge.FindByGoPath(me.current.GetGoPath())
|
||||
if check == nil {
|
||||
|
@ -105,6 +93,7 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
testGoRepo(check)
|
||||
me.forge.HumanPrintRepo(check)
|
||||
log.Info("upgrade reason:", me.reason[check])
|
||||
return
|
||||
case "/list":
|
||||
me.forge.PrintHumanTable(me.found)
|
||||
|
@ -121,7 +110,7 @@ func testGoRepo(check *gitpb.Repo) {
|
|||
data, _ := os.ReadFile(filepath.Join(check.FullPath, "go.mod"))
|
||||
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!")
|
||||
} else {
|
||||
log.Info("forge.FinalGoDepsCheck(check) failed. boo.")
|
||||
|
|
92
main.go
92
main.go
|
@ -8,8 +8,9 @@ import (
|
|||
"path/filepath"
|
||||
|
||||
"go.wit.com/dev/alexflint/arg"
|
||||
"go.wit.com/gui"
|
||||
"go.wit.com/lib/fhelp"
|
||||
"go.wit.com/lib/gadgets"
|
||||
"go.wit.com/lib/gui/prep"
|
||||
"go.wit.com/lib/gui/shell"
|
||||
"go.wit.com/lib/protobuf/forgepb"
|
||||
"go.wit.com/lib/protobuf/gitpb"
|
||||
|
@ -26,27 +27,18 @@ var argv args
|
|||
|
||||
func main() {
|
||||
me = new(autoType)
|
||||
|
||||
// parse the command line
|
||||
prep.Bash(ARGNAME, argv.DoAutoComplete) // this line should be: prep.Bash(argv)
|
||||
me.myGui = prep.Gui() // prepares the GUI package for go-args
|
||||
me.pp = arg.MustParse(&argv)
|
||||
|
||||
if argv.Bash {
|
||||
argv.doBash()
|
||||
os.Exit(0)
|
||||
}
|
||||
if len(argv.BashAuto) != 0 {
|
||||
argv.doBashAuto()
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
// load the ~/.config/forge/ config
|
||||
me.forge = forgepb.Init()
|
||||
me.forge.ScanRepoDir() // looks for new dirs, checks existing repos for changes
|
||||
me.found = new(gitpb.Repos)
|
||||
|
||||
fhelp.CheckGoModCleanExit()
|
||||
|
||||
// me.forge.ConfigPrintTable()
|
||||
os.Setenv("REPO_WORK_PATH", me.forge.GetGoSrc())
|
||||
os.Setenv("REPO_WORK_PATH", me.forge.Config.ReposDir)
|
||||
|
||||
// save the ENV var here
|
||||
me.releaseReasonS = os.Getenv("GUIRELEASE_REASON")
|
||||
|
@ -60,16 +52,20 @@ func main() {
|
|||
// user drops to a shell or xterm, then they shouldn't be set there either
|
||||
os.Unsetenv("GO111MODULE")
|
||||
|
||||
me.myGui = gui.New()
|
||||
me.myGui.InitEmbed(resources)
|
||||
me.myGui.Default()
|
||||
me.myGui.Start() // loads the GUI toolkit
|
||||
|
||||
// our main window
|
||||
me.mainWindow = me.myGui.NewWindow("GUI release manager " + VERSION)
|
||||
me.mainBox = me.mainWindow.NewBox("bw hbox", true)
|
||||
me.mainWindow = gadgets.RawBasicWindow("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.mainWindow.Make()
|
||||
me.mainWindow.Show()
|
||||
|
||||
// start the http server for polling status
|
||||
go startHTTP()
|
||||
me.mainBox = me.mainWindow.Box()
|
||||
|
||||
// sanity check of things that might be around that mess
|
||||
// up things later
|
||||
|
@ -83,49 +79,53 @@ func main() {
|
|||
|
||||
log.Info("Creating the Release Window")
|
||||
|
||||
// initialize the repo list window
|
||||
// which should be all the git repositories in ~/go/src & the .config file
|
||||
me.repos = makeRepoView()
|
||||
|
||||
// the left side of the window options
|
||||
globalDisplayOptions(me.mainBox)
|
||||
|
||||
// create the right side of the main window
|
||||
createReleaseBox(me.mainBox)
|
||||
|
||||
// disable the open repo button. this isn't really important
|
||||
// but does indicates the app (and toolkit) is working
|
||||
// this can be removed later, but in these early days, I'm using this
|
||||
// tool to release the code for this app, the gui and the gui toolkits
|
||||
// and sometimes they lie, don't display stuff, don't even disable things
|
||||
// so I can't trust even what I see. It's complicated right now still.
|
||||
me.release.openrepo.Disable()
|
||||
|
||||
// disable the gui until the repos are scanned
|
||||
me.release.box.Disable()
|
||||
me.Disable()
|
||||
|
||||
// scan in the State of all the repos
|
||||
// TODO: should not really be necessary directly after init()
|
||||
me.repos.View.ScanRepositories()
|
||||
|
||||
// todo: add this to forgepb
|
||||
me.startRepo = me.forge.FindWorkingDirRepo()
|
||||
|
||||
if _, count, _, err := me.forge.IsEverythingOnMaster(); err != nil {
|
||||
log.Info("not everything is on the master branch (", count, "repos)")
|
||||
if argv.Quick != nil {
|
||||
// quick also means ignore the master branch check
|
||||
argv.Force = true
|
||||
}
|
||||
if !argv.Force {
|
||||
os.Exit(-1)
|
||||
}
|
||||
}
|
||||
|
||||
if me.startRepo == nil {
|
||||
pwd, _ := os.Getwd()
|
||||
msg := fmt.Sprint("Can not run if pwd is not a repo", pwd)
|
||||
badExit(errors.New(msg))
|
||||
}
|
||||
me.Enable()
|
||||
|
||||
// set all branches to master & findNext()
|
||||
makePrepareRelease()
|
||||
me.forge.RillFuncError(rillPurge)
|
||||
|
||||
// intermittently scans the status indefinitly
|
||||
me.repos.View.Watchdog(func() {
|
||||
log.Info("In main()")
|
||||
// processing is done. update the repo summary box
|
||||
// me.summary.Update()
|
||||
})
|
||||
// run this each time something gets published successfully
|
||||
rePrepareRelease()
|
||||
|
||||
if findNext() {
|
||||
log.Info("prepare release findNext() returned true")
|
||||
} else {
|
||||
// check if nothing is found an exit?
|
||||
if me.found.Len() == 0 {
|
||||
log.Info("nothing found to publish")
|
||||
okExit("found nothing")
|
||||
}
|
||||
}
|
||||
me.Enable()
|
||||
me.release.box.Enable()
|
||||
|
||||
// start the http server for polling status
|
||||
startHTTP()
|
||||
}
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"go.wit.com/lib/gui/shell"
|
||||
|
@ -10,107 +13,130 @@ import (
|
|||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
func makePrepareRelease() {
|
||||
me.Disable()
|
||||
me.release.box.Disable()
|
||||
defer me.Enable()
|
||||
|
||||
// run this each time something gets published successfully
|
||||
rePrepareRelease()
|
||||
|
||||
if findNext() {
|
||||
log.Info("prepare release findNext() returned true")
|
||||
}
|
||||
|
||||
me.release.box.Enable()
|
||||
}
|
||||
|
||||
func forceReleaseVersion(repo *gitpb.Repo) {
|
||||
if argv.Minor {
|
||||
// if v1.2.3 change to v.1.3.0
|
||||
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()
|
||||
}
|
||||
}
|
||||
/*
|
||||
// empty git notes
|
||||
if _, err := repo.RunVerboseOnError([]string{"go-mod-clean", "--purge"}); err != nil {
|
||||
// log.Info("probably you don't have gomodclean")
|
||||
// log.Info(strings.Join(result.Stdout, "\n"))
|
||||
// log.Info(strings.Join(result.Stderr, "\n"))
|
||||
// repo.Run([]string{"git", "notes", "remove"})
|
||||
os.Exit(-1)
|
||||
}
|
||||
|
||||
if !runGoClean(repo, "--restore") {
|
||||
log.Info("gomodclean probably failed here. that's ok", repo.GetGoPath())
|
||||
// os.Exit(-1)
|
||||
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")
|
||||
}
|
||||
func rillGoModRestore(repo *gitpb.Repo) error {
|
||||
/*
|
||||
if repo.GetTargetVersion() == "" {
|
||||
// not set to upgrade
|
||||
moddir := filepath.Join(homedir, "go/pkg/mod", repo.GetGoPath()+"@"+rver)
|
||||
if shell.IsDir(moddir) {
|
||||
return nil
|
||||
}
|
||||
if repo.GetLastTag() == repo.GetTargetVersion() {
|
||||
return nil
|
||||
|
||||
getpath := repo.GetGoPath() + "@" + repo.GetLastTag()
|
||||
log.Infof("~/go/pkg/mod/ IS MISSING %s so I'm running go get here.", getpath)
|
||||
_, err = me.startRepo.RunVerboseOnError([]string{"go", "get", getpath})
|
||||
return err
|
||||
}
|
||||
*/
|
||||
|
||||
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
|
||||
}
|
||||
runGoClean(repo, "--restore")
|
||||
|
||||
_, err := repo.RunQuiet([]string{"go-mod-clean", "purge"})
|
||||
rillcount += 1
|
||||
if err != nil {
|
||||
log.Info("go-mod-clean purge failed", repo.GetGoPath(), err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func rillRestore(repo *gitpb.Repo) error {
|
||||
if me.forge.Config.IsReadOnly(repo.GetGoPath()) {
|
||||
return nil
|
||||
}
|
||||
if me.forge.Config.IsPrivate(repo.GetGoPath()) {
|
||||
return nil
|
||||
}
|
||||
|
||||
var err error
|
||||
if argv.Verbose {
|
||||
log.Info("go-mod-clean lax START", repo.GetGoPath())
|
||||
result := repo.RunRealtime([]string{"go-mod-clean", "lax"})
|
||||
log.Info("go-mod-clean lax END", repo.GetGoPath())
|
||||
if result.Exit != 0 {
|
||||
err = fmt.Errorf("repo %s failed %d", repo.GetGoPath(), result.Exit)
|
||||
}
|
||||
} else {
|
||||
_, err = repo.RunQuiet([]string{"go-mod-clean", "lax"})
|
||||
}
|
||||
rillcount += 1
|
||||
if err != nil {
|
||||
log.Info("go-mod-clean lax failed", repo.GetGoPath(), err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func rePrepareRelease() {
|
||||
// reload the config
|
||||
me.forge = forgepb.Init()
|
||||
me.forge.ScanRepoDir() // looks for new dirs, checks existing repos for changes
|
||||
me.found = new(gitpb.Repos)
|
||||
me.reason = make(map[*gitpb.Repo]string) // stores the reason repos need to be versioned & released
|
||||
|
||||
log.Printf("rePrepareRelease() START rill go-mod-clean lax (11 seconds?)")
|
||||
rillcount = 0
|
||||
forgepb.RillX = 2
|
||||
forgepb.RillY = 2
|
||||
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)))
|
||||
log.Printf("showRestore() (%d total repos) took:%s\n", rillcount, shell.FormatDuration(time.Since(now)))
|
||||
log.Sleep(1)
|
||||
all2 := me.forge.Repos.SortByFullPath()
|
||||
for all2.Scan() {
|
||||
check := all2.Next()
|
||||
if me.forge.Config.IsReadOnly(check.GetGoPath()) {
|
||||
continue
|
||||
}
|
||||
if me.forge.Config.IsPrivate(check.GetGoPath()) {
|
||||
continue
|
||||
}
|
||||
// this should be rare? nonexistant?
|
||||
if err := checkpkgcache(check); err != nil {
|
||||
log.Info("go get checks failed here.", err, check.GetGoPath())
|
||||
}
|
||||
}
|
||||
|
||||
all := me.forge.Repos.SortByFullPath()
|
||||
for all.Scan() {
|
||||
check := all.Next()
|
||||
|
||||
if me.forge.Config.IsReadOnly(check.GetGoPath()) {
|
||||
// can't release readonly repos
|
||||
continue
|
||||
}
|
||||
// if master != lastTag, always increment
|
||||
master := check.GetMasterVersion()
|
||||
lastTag := check.GetLastTag()
|
||||
if 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())
|
||||
log.Info("WARNING alreadyDone rePrepareRelease()", check.GetGoPath())
|
||||
continue
|
||||
}
|
||||
|
||||
if me.forge.Config.IsReadOnly(check.GetGoPath()) {
|
||||
// can't release readonly repos
|
||||
continue
|
||||
}
|
||||
|
||||
master := check.GetMasterVersion()
|
||||
lastTag := check.GetLastTag()
|
||||
|
||||
if argv.Quick != nil {
|
||||
// if argv has 'quick' don't do anything
|
||||
// that doesn't actually have a patch
|
||||
|
@ -118,11 +144,64 @@ func rePrepareRelease() {
|
|||
continue
|
||||
}
|
||||
}
|
||||
log.Info("LAST TAG", check.FullPath, master, lastTag)
|
||||
|
||||
// this is detailed. It makes sure the go.* files are absolutely perfect
|
||||
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.AppendByFullPath(check)
|
||||
log.Info("checkPublishedGodeps failed with err", check.GetGoPath(), err)
|
||||
continue
|
||||
} else {
|
||||
// log.Info("checkPublishedGodeps is ok", check.GetGoPath())
|
||||
}
|
||||
}
|
||||
|
||||
// if master != lastTag, always increment
|
||||
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 {
|
||||
log.Info("got to identical repo", check.GetGoPath(), b1, b2)
|
||||
log.Info("got to identical repo", check.GetGoPath(), oldlhash, newmhash)
|
||||
// actually identical. do nothing
|
||||
continue
|
||||
}
|
||||
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.AppendByFullPath(check)
|
||||
me.reason[check] = "master != lastTag"
|
||||
continue
|
||||
}
|
||||
|
||||
if me.forge.Config.IsPrivate(check.GetGoPath()) {
|
||||
// only checks after this are GO dep related which don't matter for private repos
|
||||
continue
|
||||
}
|
||||
|
||||
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)
|
||||
me.found.AppendByFullPath(check)
|
||||
me.reason[check] = "protobuf repo deps changed"
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -130,24 +209,35 @@ 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
|
||||
}
|
||||
log.Printf("dependancy checks indicate a new release is needed for %s\n", check.GetGoPath())
|
||||
} else {
|
||||
log.Printf("NEED RELEASE FOR %-50s err: %v\n", check.GetGoPath(), err)
|
||||
forceReleaseVersion(check)
|
||||
me.found.AppendByGoPath(check)
|
||||
// }
|
||||
me.found.AppendByFullPath(check)
|
||||
me.reason[check] = "FinalGoDepsCheckOk() failed even though master tag == last tag"
|
||||
}
|
||||
|
||||
}
|
||||
me.forge.PrintHumanTable(me.found)
|
||||
// todo: verify each found repo is on the master branch
|
||||
for repo := range me.found.IterAll() {
|
||||
if repo.CurrentBranchName != repo.MasterBranchName {
|
||||
log.Info("repo not on master branch", repo.FullPath)
|
||||
if !argv.Force {
|
||||
os.Exit(-1)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func printDone() {
|
||||
for _, gopath := range me.done {
|
||||
log.Info("printDone() THESE WERE PUBLISHED", gopath)
|
||||
}
|
||||
log.Sleep(1)
|
||||
log.Info("printDone() total finished so far:", len(me.done))
|
||||
time.Sleep(time.Second)
|
||||
}
|
||||
|
||||
func alreadyDone(repo *gitpb.Repo) bool {
|
||||
|
@ -162,3 +252,46 @@ func alreadyDone(repo *gitpb.Repo) bool {
|
|||
}
|
||||
return false
|
||||
}
|
||||
|
||||
/*
|
||||
func upgradeReason(repo *gitpb.Repo) string {
|
||||
for _, gopath := range me.reason {
|
||||
// log.Info("WARNING already done", gopath, repo.GetGoPath())
|
||||
// log.Info("WARNING already done", gopath, repo.GetGoPath())
|
||||
// log.Info("WARNING already done", gopath, repo.GetGoPath())
|
||||
if repo.GetGoPath() == gopath {
|
||||
log.Info("FOUND. RETURN TRUE. already done", gopath, repo.GetGoPath())
|
||||
return true
|
||||
}
|
||||
}
|
||||
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
|
||||
}
|
||||
}
|
||||
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
|
||||
}
|
||||
|
|
191
releaseBox.go
191
releaseBox.go
|
@ -3,14 +3,14 @@ package main
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"go.wit.com/gui"
|
||||
"go.wit.com/log"
|
||||
|
||||
"go.wit.com/lib/gadgets"
|
||||
"go.wit.com/lib/gui/repolist"
|
||||
"go.wit.com/lib/gui/shell"
|
||||
"go.wit.com/lib/protobuf/gitpb"
|
||||
)
|
||||
|
||||
type releaseStruct struct {
|
||||
|
@ -25,14 +25,14 @@ type releaseStruct struct {
|
|||
releaseVersionB *gui.Node
|
||||
reason *gadgets.BasicEntry
|
||||
|
||||
openrepo *gui.Node
|
||||
// openrepo *gui.Node
|
||||
|
||||
goGetB *gui.Node
|
||||
checkGoSumB *gui.Node
|
||||
checkDirtyB *gui.Node
|
||||
sendVersionB *gui.Node
|
||||
checkSafeB *gui.Node
|
||||
whitelist map[string]*repolist.RepoRow
|
||||
// whitelist map[string]*repolist.RepoRow
|
||||
}
|
||||
|
||||
func (w *autoType) Disable() {
|
||||
|
@ -51,14 +51,20 @@ func createReleaseBox(box *gui.Node) {
|
|||
|
||||
me.release.releaseVersionB = me.release.grid.NewButton("release version", func() {
|
||||
buttonDisable()
|
||||
if doRelease() {
|
||||
fpath := me.current.FullPath
|
||||
if err := doRelease(); err == nil {
|
||||
buttonEnable()
|
||||
log.Info("doRelease() worked")
|
||||
log.Info("doRelease() worked", fpath)
|
||||
} else {
|
||||
log.Info("doRelease() failed")
|
||||
log.Info("doRelease() failed", err, fpath)
|
||||
log.Info("doRelease() FAILED", err, fpath)
|
||||
log.Info("doRelease() FAILED", err, fpath)
|
||||
log.Info("doRelease() FAILED", err, fpath)
|
||||
}
|
||||
skipToNext()
|
||||
me.forge.PrintHumanTable(me.found)
|
||||
})
|
||||
me.release.grid.NewButton("Find Next Releasable", func() {
|
||||
me.release.grid.NewButton("Find Next", func() {
|
||||
me.Disable()
|
||||
defer me.Enable()
|
||||
if findNext() {
|
||||
|
@ -66,15 +72,18 @@ func createReleaseBox(box *gui.Node) {
|
|||
return
|
||||
}
|
||||
})
|
||||
me.release.grid.NewButton("Show Next", func() {
|
||||
check := me.current
|
||||
if check == nil {
|
||||
log.Info("boo, current is missing", me.current.GetGoPath())
|
||||
return
|
||||
}
|
||||
testGoRepo(check)
|
||||
me.forge.HumanPrintRepo(check)
|
||||
})
|
||||
me.release.grid.NextRow()
|
||||
|
||||
me.release.repo = gadgets.NewOneLiner(me.release.grid, "repo")
|
||||
me.release.openrepo = me.release.grid.NewButton("Configure", func() {
|
||||
if repov := me.repos.View.FindByPath(me.current.GetGoPath()); repov != nil {
|
||||
repov.Status.Toggle()
|
||||
}
|
||||
})
|
||||
me.release.openrepo.Disable()
|
||||
me.release.grid.NextRow()
|
||||
me.release.status = gadgets.NewOneLiner(me.release.grid, "status")
|
||||
me.release.grid.NextRow()
|
||||
|
@ -92,143 +101,71 @@ func createReleaseBox(box *gui.Node) {
|
|||
|
||||
me.autoWorkingPwd = gadgets.NewOneLiner(me.release.grid, "working directory (pwd)")
|
||||
me.release.grid.NextRow()
|
||||
// me.userHomePwd = gadgets.NewOneLiner(me.release.grid, "user home")
|
||||
// me.release.grid.NextRow()
|
||||
me.goSrcPwd = gadgets.NewOneLiner(me.release.grid, "go src home")
|
||||
me.release.grid.NextRow()
|
||||
|
||||
// me.userHomePwd.SetText(homeDir)
|
||||
me.goSrcPwd.SetText(me.forge.GetGoSrc())
|
||||
me.goSrcPwd.SetText(me.forge.Config.ReposDir)
|
||||
|
||||
group := me.release.box.NewGroup("Run on Current Repo")
|
||||
grid := group.NewGrid("buildOptions", 0, 0)
|
||||
|
||||
grid.NewButton("whitelist", func() {
|
||||
// tmp := me.current.GoState()
|
||||
if repov := me.repos.View.FindByPath(me.current.GetGoPath()); repov != nil {
|
||||
log.Info("trying to whitelist repo", me.current.GetGoPath())
|
||||
}
|
||||
findNext()
|
||||
})
|
||||
|
||||
grid.NextRow()
|
||||
|
||||
group = me.release.box.NewGroup("Process against all repos")
|
||||
group = me.release.box.NewGroup("Publish until done")
|
||||
grid = group.NewGrid("buildOptions", 0, 0)
|
||||
grid.NewButton("doRelease() all", func() {
|
||||
buttonDisable()
|
||||
// rather than loop forever, at least limit this to the number of repos
|
||||
// incase something, somewhere, goes wrong
|
||||
ok, duration := doReleaseAll()
|
||||
s := fmt.Sprint(duration)
|
||||
log.Info("release returned", ok, "and ran for", s, "findCounter =", findCounter)
|
||||
if !findOk {
|
||||
log.Info("doRelease() immediately end something went wrong last time. findOk == false")
|
||||
return
|
||||
}
|
||||
first := findCounter
|
||||
if findCounter != 0 {
|
||||
log.Info("should try thsi doRelease() loop again since findCounter =", findCounter)
|
||||
ok, duration := doReleaseAll()
|
||||
s := fmt.Sprint(duration)
|
||||
log.Info("release returned", ok, "and ran for", s, "findCounter =", findCounter)
|
||||
}
|
||||
if !findOk {
|
||||
log.Info("doRelease() immediately end something went wrong last time. findOk == false")
|
||||
return
|
||||
}
|
||||
second := findCounter
|
||||
log.Info("doReleaseAll() first =", first, "second =", second)
|
||||
if first == 0 {
|
||||
log.Info("doReleaseAll() first is 0. everything is done. second is", second)
|
||||
log.Info("exit() here safely")
|
||||
me.forge.ConfigSave()
|
||||
printDone()
|
||||
okExit("")
|
||||
return
|
||||
}
|
||||
|
||||
if first != second {
|
||||
// try a third time
|
||||
log.Info("doReleaseAll() first second do not match. findNext()")
|
||||
findNext()
|
||||
ok, duration := doReleaseAll()
|
||||
s := fmt.Sprint(duration)
|
||||
log.Info("release returned", ok, "and ran for", s, "findCounter =", findCounter)
|
||||
third := findCounter
|
||||
log.Info("doReleaseAll() findCounter first =", first, "second =", second, "third =", third)
|
||||
if !findOk {
|
||||
log.Info("doRelease() immediately end something went wrong last time. findOk == false")
|
||||
return
|
||||
}
|
||||
if (second == 0) && (third == 0) {
|
||||
log.Info("doReleaseAll() SaveConfig() here and Exit(0)")
|
||||
me.forge.ConfigSave()
|
||||
okExit("")
|
||||
}
|
||||
} else {
|
||||
log.Info("doReleaseAll() first second match. something has gone terribly wrong")
|
||||
log.Info("killing guireleaser is a bad idea here. it will potentially loose state")
|
||||
log.Info("the only way now is to parse 'go list' or ~/go/pkg/mod/<gopath>/go.sum files")
|
||||
log.Info("to determine the last known version to make sure everything is redone correctly")
|
||||
log.Info("this is the worst case. the better idea is to make sure it never fails")
|
||||
log.Info("and restarts correctly where it left off. That might not be possible?")
|
||||
log.Info("because 'go get @foo.com/bar@latest' appears to be global and so")
|
||||
log.Info("some go.sum files might be correct when some are not actually published")
|
||||
log.Info("TODO: is this true or not?")
|
||||
}
|
||||
|
||||
doReleaseAll()
|
||||
buttonEnable()
|
||||
})
|
||||
grid.NextRow()
|
||||
|
||||
group = me.release.box.NewGroup("experimental and potentially dangerous stuff")
|
||||
grid = group.NewGrid("buildOptions", 0, 0)
|
||||
|
||||
me.setBranchesToMasterB = grid.NewButton("set all branches to master", func() {
|
||||
me.Disable()
|
||||
defer me.Enable()
|
||||
/*
|
||||
if setAllBranchesToMaster() {
|
||||
// if it succeeds, disable this button
|
||||
me.setBranchesToMasterB.Disable()
|
||||
}
|
||||
*/
|
||||
})
|
||||
grid.NextRow()
|
||||
}
|
||||
|
||||
func doReleaseAll() (bool, time.Duration) {
|
||||
var worked bool = true
|
||||
findCounter = 0
|
||||
duration := repolist.TimeFunction(func() {
|
||||
loop := me.repos.View.ReposSortByName()
|
||||
for loop.Scan() {
|
||||
loop.Repo()
|
||||
if !findOk {
|
||||
log.Info("doRelease() immediately end something went wrong last time. findOk == false")
|
||||
worked = false
|
||||
func doReleaseAll() {
|
||||
count := 0
|
||||
for {
|
||||
log.Info("START doRelease() LOOP count =", count, "len me.done =", len(me.done))
|
||||
if err := doRelease(); err != nil {
|
||||
break
|
||||
}
|
||||
if doRelease() {
|
||||
log.Info("doRelease() worked. findCounter =", findCounter)
|
||||
} else {
|
||||
if os.Getenv("FindNextDone") == "true" {
|
||||
log.Info("findNext says it was done. findCounter =", findCounter)
|
||||
log.Info("findNext says it was done. findCounter =", findCounter)
|
||||
log.Info("we can exit here")
|
||||
if err := skipToNext(); err != nil {
|
||||
break
|
||||
}
|
||||
if me.release.status.String() == "ALL DONE?" {
|
||||
log.Info("maybe ALL DONE?. findCounter =", findCounter)
|
||||
worked = true
|
||||
}
|
||||
log.Info("doRelease() failed. findCounter =", findCounter)
|
||||
worked = false
|
||||
count += 1
|
||||
if count > me.forge.Repos.Len() {
|
||||
// never allow a loop longer than all the known repos
|
||||
// this probably doesn't matter, but often this code is wrong
|
||||
// so this is a safety check. never remove this check.
|
||||
break
|
||||
}
|
||||
}
|
||||
})
|
||||
return worked, duration
|
||||
}
|
||||
|
||||
func skipToNext() error {
|
||||
shell.RunVerbose([]string{"forge", "dirty"})
|
||||
log.Info("Sleeping for 2 seconds for no reason.")
|
||||
time.Sleep(1)
|
||||
me.forge.ScanRepoDir() // looks for new dirs, checks existing repos for changes
|
||||
me.found = new(gitpb.Repos)
|
||||
|
||||
me.current.ReloadCheck()
|
||||
me.forge.SetConfigSave(true)
|
||||
me.forge.ConfigSave()
|
||||
log.Info("sleep 2")
|
||||
time.Sleep(2 * time.Second)
|
||||
printDone()
|
||||
|
||||
rePrepareRelease()
|
||||
findNext()
|
||||
if me.current == nil {
|
||||
log.Info("NOT GOOD TO RUN ANOTHER DAY")
|
||||
log.Info("took out all the loop code")
|
||||
setCurrentRepo(nil, "loop by hand motherfucker", "fucknuts")
|
||||
return fmt.Errorf("findNext returned next repo == nil")
|
||||
}
|
||||
log.Info("GOOD TO RUN ANOTHER DAY ON:", me.current.GetGoPath())
|
||||
return nil
|
||||
}
|
||||
|
||||
func buttonDisable() {
|
||||
|
|
73
repoview.go
73
repoview.go
|
@ -1,73 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"go.wit.com/lib/gadgets"
|
||||
"go.wit.com/lib/gui/repolist"
|
||||
"go.wit.com/log"
|
||||
|
||||
"go.wit.com/gui"
|
||||
)
|
||||
|
||||
type repoWindow struct {
|
||||
win *gadgets.BasicWindow
|
||||
box *gui.Node
|
||||
View *repolist.RepoList
|
||||
}
|
||||
|
||||
func (r *repoWindow) Hidden() bool {
|
||||
return r.win.Hidden()
|
||||
}
|
||||
|
||||
func (r *repoWindow) Show() {
|
||||
r.win.Show()
|
||||
}
|
||||
|
||||
func (r *repoWindow) Hide() {
|
||||
r.win.Hide()
|
||||
}
|
||||
|
||||
func (r *repoWindow) Disable() {
|
||||
r.box.Disable()
|
||||
}
|
||||
|
||||
func (r *repoWindow) Enable() {
|
||||
r.box.Enable()
|
||||
}
|
||||
|
||||
// you can only have one of these
|
||||
func makeRepoView() *repoWindow {
|
||||
if me.repos != nil {
|
||||
return me.repos
|
||||
}
|
||||
r := new(repoWindow)
|
||||
r.win = gadgets.RawBasicWindow("GUI repositories in ~/go/src/")
|
||||
r.win.Make()
|
||||
|
||||
r.box = r.win.Box().NewBox("bw vbox", false)
|
||||
r.win.Custom = func() {
|
||||
log.Warn("GOT HERE: main() gadgets.NewBasicWindow() close")
|
||||
log.Warn("Should I do something special here?")
|
||||
}
|
||||
|
||||
// reposbox.SetExpand(false)
|
||||
group1 := r.box.NewGroup("Run on all repos:")
|
||||
|
||||
hbox := group1.Box()
|
||||
// hbox.Horizontal()
|
||||
hbox.Vertical()
|
||||
|
||||
r.View = repolist.InitBox(me.forge, r.box)
|
||||
r.View.Enable()
|
||||
|
||||
r.View.ScanRepositories()
|
||||
|
||||
/*
|
||||
r.View = repolist.GuireleaserView(r.box)
|
||||
|
||||
showncount := r.View.MirrorShownCount()
|
||||
box2.Append(showncount)
|
||||
duration := r.View.MirrorScanDuration()
|
||||
box2.Append(duration)
|
||||
*/
|
||||
return r
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
* you can put toolkit .so binaries here
|
39
structs.go
39
structs.go
|
@ -5,6 +5,7 @@ import (
|
|||
"go.wit.com/dev/alexflint/arg"
|
||||
"go.wit.com/gui"
|
||||
"go.wit.com/lib/gadgets"
|
||||
"go.wit.com/lib/gui/prep"
|
||||
"go.wit.com/lib/protobuf/forgepb"
|
||||
"go.wit.com/lib/protobuf/gitpb"
|
||||
)
|
||||
|
@ -13,7 +14,7 @@ var me *autoType
|
|||
|
||||
type autoType struct {
|
||||
pp *arg.Parser // for parsing the command line args. Yay to alexf lint!
|
||||
myGui *gui.Node // the gui handle itself
|
||||
myGui *prep.GuiPrep // the gui handle itself
|
||||
releaseReasonS string // = "gocui dropdown select"
|
||||
release releaseStruct // notsure
|
||||
reposbox *gui.Node // notsure
|
||||
|
@ -22,6 +23,7 @@ type autoType struct {
|
|||
current *gitpb.Repo // tracks the next repo to publish
|
||||
found *gitpb.Repos // stores the list of repos to process things on
|
||||
done []string // gopaths for repos already published
|
||||
reason map[*gitpb.Repo]string // the reason this package is going to be updated
|
||||
|
||||
// this is the repo we are starting in
|
||||
// make sure it never changes so go.mod and go.sum are always there
|
||||
|
@ -29,35 +31,10 @@ type autoType struct {
|
|||
startRepo *gitpb.Repo
|
||||
|
||||
// guireleaser window
|
||||
mainWindow *gui.Node
|
||||
mainWindow *gadgets.BasicWindow
|
||||
mainBox *gui.Node
|
||||
|
||||
// our view of the repositories
|
||||
repos *repoWindow
|
||||
|
||||
// your customized repo preferences and settings
|
||||
forge *forgepb.Forge
|
||||
|
||||
// #### autotypist Global Build Options
|
||||
// what to change all the branches to
|
||||
// so, as a developer, you can move all the repos
|
||||
// to the 'devel' branch and then test a devel branch build
|
||||
// then switch back to your 'username' branch and do a build there
|
||||
// toMoveToBranch string
|
||||
|
||||
// displays the preferred names used for the repo tree state
|
||||
// mainBranch *gadgets.BasicCombobox
|
||||
// develBranch *gadgets.BasicCombobox
|
||||
// userBranch *gadgets.BasicCombobox
|
||||
|
||||
// this button will regenerate everyones go.mod & go.sum
|
||||
rerunGoMod *gui.Node
|
||||
|
||||
// if checked, will stop trying to os.Exec() things after failure
|
||||
stopOnErrors *gui.Node
|
||||
|
||||
// button to attempt to autorebuild
|
||||
autoRebuildButton *gui.Node
|
||||
forge *forgepb.Forge // your customized repo preferences and settings
|
||||
|
||||
// checkbox for --dry-run
|
||||
autoDryRun *gui.Node
|
||||
|
@ -83,9 +60,3 @@ type autoType struct {
|
|||
// show the time it took to do a scan
|
||||
duration *gui.Node
|
||||
}
|
||||
|
||||
/*
|
||||
func (my *autoType) GoSrcPath() string {
|
||||
return my.goSrcPwd.String()
|
||||
}
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue