Compare commits
No commits in common. "master" and "v0.22.36" have entirely different histories.
71
Makefile
71
Makefile
|
@ -14,30 +14,27 @@ vet:
|
||||||
|
|
||||||
build:
|
build:
|
||||||
echo "build it!"
|
echo "build it!"
|
||||||
touch resources/blank.so
|
|
||||||
-rm resources/*.so
|
-rm resources/*.so
|
||||||
-mkdir resources/
|
-mkdir resources/
|
||||||
-cp -a ~/go/src/go.wit.com/toolkits/*/*.so resources/
|
cp -a ~/go/src/go.wit.com/toolkits/*/*.so resources/
|
||||||
touch resources/blank.so
|
|
||||||
GO111MODULE=off go build \
|
GO111MODULE=off go build \
|
||||||
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
|
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f go.*
|
|
||||||
-rm resources/*.so
|
|
||||||
touch resources/blank.so
|
|
||||||
|
|
||||||
install: goimports
|
install: goimports
|
||||||
touch resources/blank.so
|
|
||||||
-rm resources/*.so
|
-rm resources/*.so
|
||||||
# -cp -a ~/go/src/go.wit.com/toolkits/*/*.so resources/
|
cp -a ~/go/src/go.wit.com/toolkits/*/*.so resources/
|
||||||
touch resources/blank.so
|
|
||||||
GO111MODULE=off go install \
|
GO111MODULE=off go install \
|
||||||
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
|
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
|
||||||
|
|
||||||
check-git-clean:
|
check-git-clean:
|
||||||
@git diff-index --quiet HEAD -- || (echo "Git repository is dirty, please commit your changes first"; exit 1)
|
@git diff-index --quiet HEAD -- || (echo "Git repository is dirty, please commit your changes first"; exit 1)
|
||||||
|
|
||||||
|
redomod:
|
||||||
|
rm -f go.*
|
||||||
|
GO111MODULE= go mod init
|
||||||
|
GO111MODULE= go mod tidy
|
||||||
|
go mod edit -go=1.20
|
||||||
|
|
||||||
curl-help:
|
curl-help:
|
||||||
curl --silent http://localhost:9419/help
|
curl --silent http://localhost:9419/help
|
||||||
|
|
||||||
|
@ -55,11 +52,18 @@ curl-setBranchesToMasterB:
|
||||||
findNext:
|
findNext:
|
||||||
curl --silent http://localhost:9419/findNext
|
curl --silent http://localhost:9419/findNext
|
||||||
|
|
||||||
|
fixNext:
|
||||||
|
curl --silent http://localhost:9419/fixNext
|
||||||
|
|
||||||
showNext:
|
showNext:
|
||||||
curl --silent http://localhost:9419/showNext
|
curl --silent http://localhost:9419/showNext
|
||||||
|
|
||||||
|
testNext:
|
||||||
|
curl --silent http://localhost:9419/testNext
|
||||||
|
|
||||||
doRelease:
|
doRelease:
|
||||||
reset
|
reset
|
||||||
|
make curl-list-changed
|
||||||
make showNext
|
make showNext
|
||||||
sleep 10
|
sleep 10
|
||||||
curl --silent http://localhost:9419/doRelease
|
curl --silent http://localhost:9419/doRelease
|
||||||
|
@ -85,41 +89,14 @@ curl-incrementAllTargetVersions:
|
||||||
list-release-notdone:
|
list-release-notdone:
|
||||||
curl --silent http://localhost:9419/releaseList?readonly=true
|
curl --silent http://localhost:9419/releaseList?readonly=true
|
||||||
|
|
||||||
safe-build: install
|
# only show repos that need to be merged to the master branch
|
||||||
# forge list --private
|
curl-list-changed:
|
||||||
wit-test install --verbose
|
curl --silent http://localhost:9419/list?perfect=false
|
||||||
# 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
|
# include repos that you probably can't git push commits
|
||||||
wit-test install --verbose
|
curl-list-everything:
|
||||||
# rm -f go.* ; git checkout go.mod ;cd ~/go/src/go.wit.com/lib/xgb/ && time GUIRELEASE_REASON="safe-build" guireleaser --gui andlabs quick
|
curl --silent http://localhost:9419/list?readonly=true
|
||||||
sudo "wit update"
|
|
||||||
|
|
||||||
autocomplete:
|
curl-file-for-go.wit.com:
|
||||||
guireleaser --bash > ~/.local/share/bash-completion/completions/guireleaser
|
curl --silent http://localhost:9419/goweblist?readonly=true
|
||||||
|
curl --silent http://localhost:9419/goweblist?readonly=true |sort > ~/go.wit.com.versions
|
||||||
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
|
@ -1,8 +0,0 @@
|
||||||
notes on what to fix next
|
|
||||||
|
|
||||||
go-args make patches for alexflint
|
|
||||||
|
|
||||||
go-mod-clean --restore *.pb.go files
|
|
||||||
go-mod-clean set ctime on files
|
|
||||||
|
|
||||||
guireleaser change "title small" to the package being updated"
|
|
64
argv.go
64
argv.go
|
@ -1,11 +1,5 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
"os/user"
|
|
||||||
)
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
this parses the command line arguements
|
this parses the command line arguements
|
||||||
|
|
||||||
|
@ -13,26 +7,14 @@ import (
|
||||||
*/
|
*/
|
||||||
|
|
||||||
type args struct {
|
type args struct {
|
||||||
Quick *QuickCmd `arg:"subcommand:quick" help:"only do repos with patches"`
|
// Repo string `arg:"positional" help:"go import path"`
|
||||||
|
// Increment bool `arg:"--increment" help:"auto increment"`
|
||||||
|
// Release bool `arg:"--release" help:"do a release an exit"`
|
||||||
DryRun bool `arg:"--dry-run,env:DRYRUN" help:"don't actually do the release"`
|
DryRun bool `arg:"--dry-run,env:DRYRUN" help:"don't actually do the release"`
|
||||||
Minor bool `arg:"--minor" help:"increment minor verion numbers"`
|
Fix bool `arg:"--fix" help:"run fixGoMod() on startup"`
|
||||||
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"`
|
Reason string `arg:"--reason" help:"tag message"`
|
||||||
Force bool `arg:"--force" help:"try harder than normal"`
|
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"`
|
||||||
Bash bool `arg:"--bash" help:"generate bash completion"`
|
|
||||||
BashAuto []string `arg:"--auto-complete" help:"does the actual autocompletion"`
|
|
||||||
}
|
|
||||||
|
|
||||||
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 {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a args) Description() string {
|
func (a args) Description() string {
|
||||||
|
@ -47,39 +29,3 @@ the repositories in the go.sum file using git clone`
|
||||||
func (args) Version() string {
|
func (args) Version() string {
|
||||||
return "guireleaser " + VERSION
|
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)
|
|
||||||
}
|
|
||||||
|
|
213
doRelease.go
213
doRelease.go
|
@ -2,34 +2,32 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fmt"
|
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/go-cmd/cmd"
|
||||||
|
|
||||||
"go.wit.com/lib/gui/shell"
|
"go.wit.com/lib/gui/shell"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func doRelease() error {
|
func doRelease() bool {
|
||||||
check := me.current
|
log.Info("doRelease() on", me.current.Name())
|
||||||
log.Info("doRelease() on", me.current.GetGoPath())
|
|
||||||
if !findOk {
|
if !findOk {
|
||||||
log.Info("doRelease() immediately end something went wrong last time. findOk == false")
|
log.Info("doRelease() immediately end something went wrong last time. findOk == false")
|
||||||
return fmt.Errorf("findOK = false %s", check.GetGoPath())
|
return false
|
||||||
}
|
}
|
||||||
// double check release version logic
|
// double check release version logic
|
||||||
if me.release.releaseVersionB.String() != "release version "+me.release.version.String() {
|
if me.release.releaseVersionB.String() != "release version "+me.release.version.String() {
|
||||||
log.Warn("something went wrong with the release.version:", me.release.version.String())
|
log.Warn("something went wrong with the release.version:", me.release.version.String())
|
||||||
return fmt.Errorf("GUI lied %s", check.GetGoPath())
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.HasPrefix(me.release.version.String(), "v") {
|
if strings.HasPrefix(me.release.version.String(), "v") {
|
||||||
log.Warn("everything is ok. version starts with v.", me.release.version.String())
|
log.Warn("everything is ok. version starts with v.", me.release.version.String())
|
||||||
} else {
|
} else {
|
||||||
log.Warn("version does not start with v.", me.release.version.String())
|
log.Warn("version does not start with v.", me.release.version.String())
|
||||||
return fmt.Errorf("release does not start with a v %s", check.GetGoPath())
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if shell.Exists("go.mod") {
|
if shell.Exists("go.mod") {
|
||||||
|
@ -37,64 +35,34 @@ func doRelease() error {
|
||||||
} else {
|
} else {
|
||||||
pwd, _ := os.Getwd()
|
pwd, _ := os.Getwd()
|
||||||
log.Info("go.mod missing in working dir", pwd)
|
log.Info("go.mod missing in working dir", pwd)
|
||||||
return fmt.Errorf("go.mod missing %s", check.GetGoPath())
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
curName := me.current.GetCurrentBranchName()
|
curName := me.current.Status.GetCurrentBranchName()
|
||||||
mName := me.current.GetMasterBranchName()
|
mName := me.current.Status.GetMasterBranchName()
|
||||||
if curName != mName {
|
if curName != mName {
|
||||||
log.Info("\trepo is not working from main branch", curName, "!=", mName)
|
log.Info("\trepo is not working from main branch", curName, "!=", mName)
|
||||||
return fmt.Errorf("not on main branch %s", check.GetGoPath())
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if alreadyDone(check) {
|
check := me.forge.Repos.FindByGoPath(me.current.GoPath())
|
||||||
// means it was already published
|
if check == nil {
|
||||||
// protects against logic errors that might result
|
log.Info("boo, you didn't git clone", me.current.GoPath())
|
||||||
// in an infinite loop
|
return false
|
||||||
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.ReloadCheck()
|
|
||||||
return fmt.Errorf("already released %s", check.GetGoPath())
|
|
||||||
}
|
}
|
||||||
|
if !me.forge.FinalGoDepsCheckOk(check) {
|
||||||
// check if the git tag already exists somehow
|
log.Info("the go.mod file is wrong. fix it here?", check.GetGoPath())
|
||||||
testtag := me.release.version.String()
|
os.Exit(-1)
|
||||||
if check.LocalTagExists(testtag) {
|
return false
|
||||||
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 check.GoPath == me.startRepo.GoPath {
|
||||||
if me.forge.Config.IsPrivate(me.current.GetGoPath()) {
|
log.Info("CAN NOT SELF UPDATE.", check.GoPath, "is the same as os.Getwd()")
|
||||||
// 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 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 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()")
|
|
||||||
log.Info("go get must be run from somewhere else other than startRepo")
|
log.Info("go get must be run from somewhere else other than startRepo")
|
||||||
log.Info("chdir to autotypist if it exists")
|
log.Info("chdir to autotypist if it exists")
|
||||||
msg := fmt.Sprint("CAN NOT SELF UPDATE.", check.GetGoPath(), "is the same as os.Getwd()")
|
os.Exit(-1)
|
||||||
badExit(errors.New(msg))
|
|
||||||
}
|
}
|
||||||
if !me.startRepo.Exists("go.mod") {
|
if !me.startRepo.Exists("go.mod") {
|
||||||
log.Info("go.sum missing in", me.startRepo.GetGoPath())
|
log.Info("go.sum missing in", me.startRepo.GoPath)
|
||||||
log.Info("pick a different repo here")
|
log.Info("pick a different repo here")
|
||||||
log.Info("todo: error out earlier knowing this will upgrade")
|
log.Info("todo: error out earlier knowing this will upgrade")
|
||||||
log.Info("versions", me.startRepo.GetTargetVersion(), me.startRepo.GetMasterVersion())
|
log.Info("versions", me.startRepo.GetTargetVersion(), me.startRepo.GetMasterVersion())
|
||||||
|
@ -104,33 +72,15 @@ func doRelease() error {
|
||||||
log.Info("\ttag and push", curName, me.release.version.String(), me.releaseReasonS)
|
log.Info("\ttag and push", curName, me.release.version.String(), me.releaseReasonS)
|
||||||
|
|
||||||
if err := check.ValidGoSum(); err != nil {
|
if err := check.ValidGoSum(); err != nil {
|
||||||
log.Info("ValidGoSum() error", check.GetGoPath(), err)
|
log.Info("ValidGoSum() error", check.GoPath, err)
|
||||||
msg := fmt.Sprint("ValidGoSum() error", check.GetGoPath(), err)
|
os.Exit(-1)
|
||||||
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 all [][]string
|
||||||
var autogen []string
|
var autogen []string
|
||||||
all = append(all, []string{"git", "add", "-f", "go.mod"})
|
all = append(all, []string{"git", "add", "-f", "go.mod"})
|
||||||
autogen = append(autogen, "go.mod")
|
autogen = append(autogen, "go.mod")
|
||||||
if check.GoInfo.GoPrimitive {
|
if check.GoPrimitive {
|
||||||
// don't add go.sum here. TODO: check for go.sum file and fail
|
// don't add go.sum here. TODO: check for go.sum file and fail
|
||||||
} else {
|
} else {
|
||||||
all = append(all, []string{"git", "add", "-f", "go.sum"})
|
all = append(all, []string{"git", "add", "-f", "go.sum"})
|
||||||
|
@ -141,8 +91,7 @@ func doRelease() error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Info("\tERROR: There are protobuf files, but they are not compiled")
|
log.Info("\tERROR: There are protobuf files, but they are not compiled")
|
||||||
log.Info("\tERROR: can not continue")
|
log.Info("\tERROR: can not continue")
|
||||||
msg := fmt.Sprint("ERROR: There are protobuf files, but they are not compiled")
|
os.Exit(-1)
|
||||||
badExit(errors.New(msg))
|
|
||||||
}
|
}
|
||||||
log.Info("\tshould add the protobuf files here")
|
log.Info("\tshould add the protobuf files here")
|
||||||
log.Info("\tcompiled files found:", compiled)
|
log.Info("\tcompiled files found:", compiled)
|
||||||
|
@ -163,14 +112,13 @@ func doRelease() error {
|
||||||
cname := check.GetCurrentBranchName()
|
cname := check.GetCurrentBranchName()
|
||||||
if err := check.AutogenSave(autogen, cname, true); err != nil {
|
if err := check.AutogenSave(autogen, cname, true); err != nil {
|
||||||
log.Info("AutogenSave() error", err)
|
log.Info("AutogenSave() error", err)
|
||||||
msg := fmt.Sprint("AutogenSave() error", err)
|
os.Exit(-1)
|
||||||
badExit(errors.New(msg))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if !me.current.RunAll(all) {
|
if !me.current.Status.DoAll(all) {
|
||||||
log.Info("failed to make new release", me.release.version.String())
|
log.Info("failed to make new release", me.release.version.String())
|
||||||
findOk = false
|
findOk = false
|
||||||
return fmt.Errorf("setting findOK = false %s", check.GetGoPath())
|
return false
|
||||||
}
|
}
|
||||||
log.Info("RELEASE OK")
|
log.Info("RELEASE OK")
|
||||||
|
|
||||||
|
@ -179,21 +127,36 @@ func doRelease() error {
|
||||||
time.Sleep(3 * time.Second)
|
time.Sleep(3 * time.Second)
|
||||||
// this can fail to update, try it again after sleep(3s)
|
// this can fail to update, try it again after sleep(3s)
|
||||||
if !doPublishVersion() {
|
if !doPublishVersion() {
|
||||||
log.Info("PUBLISH FAILED gopath=%s", check.GetGoPath())
|
log.Info("PUBLISH FAILED")
|
||||||
findOk = false
|
findOk = false
|
||||||
return fmt.Errorf("PUBLISH FAILED gopath=%s", check.GetGoPath())
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pb := me.forge.Repos.FindByGoPath(me.current.GoPath())
|
||||||
|
if pb != nil {
|
||||||
|
pb.UpdatePublished()
|
||||||
|
/* remove. earlier protected against nil
|
||||||
|
if !pb.IsPrimitive() {
|
||||||
|
loop := pb.Published.SortByGoPath()
|
||||||
|
for loop.Scan() {
|
||||||
|
t := loop.Next()
|
||||||
|
log.Info("new Published dep:", t.GetGoPath(), t.GetVersion())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
me.forge.Repos.ConfigSave()
|
||||||
|
}
|
||||||
|
|
||||||
log.Info("PUBLISH OK")
|
log.Info("PUBLISH OK")
|
||||||
// me.current.SetGoState("RELEASED")
|
// me.current.SetGoState("RELEASED")
|
||||||
|
|
||||||
// unwind and re-tag. Now that the go.mod and go.sum are published, revert
|
// unwind and re-tag. Now that the go.mod and go.sum are published, revert
|
||||||
// to the development branch
|
// to the development branch
|
||||||
if !me.current.RevertMasterToDevel() {
|
if !me.current.Status.RevertMasterToDevel() {
|
||||||
log.Info("Revert Failed")
|
log.Info("Revert Failed")
|
||||||
findOk = false
|
findOk = false
|
||||||
return fmt.Errorf("REVERT FAILED %s", check.GetGoPath())
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// update tag
|
// update tag
|
||||||
|
@ -203,41 +166,99 @@ func doRelease() error {
|
||||||
retag = append(retag, []string{"git", "tag", "-m", me.releaseReasonS, me.release.version.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()})
|
retag = append(retag, []string{"git", "push", "origin", me.release.version.String()})
|
||||||
|
|
||||||
if !me.current.RunAll(retag) {
|
if err := check.AutogenRestore(cname); err != nil {
|
||||||
|
log.Info("AutogenRestore() failed", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if !me.current.Status.DoAll(retag) {
|
||||||
log.Info("retag failed")
|
log.Info("retag failed")
|
||||||
findOk = false
|
findOk = false
|
||||||
return fmt.Errorf("RETAG FAILED %s", check.GetGoPath())
|
return false
|
||||||
}
|
}
|
||||||
log.Info("EVERYTHING OK. RERELEASED", me.current.GetGoPath())
|
log.Info("EVERYTHING OK. RERELEASED", me.current.Name())
|
||||||
|
|
||||||
return nil
|
// 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)
|
||||||
|
os.Exit(-1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// it's necessary to recreate the the files here
|
||||||
|
// safe to do this here. everything has been published
|
||||||
|
fixGodeps(check)
|
||||||
|
|
||||||
|
// update the values in the GUI
|
||||||
|
me.current.NewScan()
|
||||||
|
|
||||||
|
// 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 := PrintReleaseReport("", "")
|
||||||
|
log.Info("count =", count)
|
||||||
|
os.Setenv("FindNextDone", "true")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
log.Info("GOOD TO RUN ANOTHER DAY ON:", me.current.Name())
|
||||||
|
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.Repos.FindByGoPath(me.current.GoPath())
|
||||||
|
if check == nil {
|
||||||
|
log.Info("boo, you didn't git clone", me.current.GoPath())
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if findFix {
|
||||||
|
fixGodeps(check)
|
||||||
|
}
|
||||||
|
if me.forge.FinalGoDepsCheckOk(check) {
|
||||||
|
// the go.sum file is ok to release
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// this pulls the new tag from the golang package repository
|
// this pulls the new tag from the golang package repository
|
||||||
// to insert the new version
|
// to insert the new version
|
||||||
func doPublishVersion() bool {
|
func doPublishVersion() bool {
|
||||||
gopath := me.current.GetGoPath()
|
gopath := me.current.GoPath()
|
||||||
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)
|
||||||
|
|
||||||
if me.forge.Config.IsPrivate(me.current.GetGoPath()) {
|
if me.current.Status.IsPrivate() {
|
||||||
// do not self update private repos
|
// do not self update private repos
|
||||||
log.Info("This is a private repo and can not be self checked")
|
log.Info("This is a private repo and can not be self checked")
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// try to pull from google
|
// try to pull from google
|
||||||
if gopath == me.startRepo.GetGoPath() {
|
var result cmd.Status
|
||||||
|
if gopath == me.startRepo.GoPath {
|
||||||
log.Info("CAN NOT SELF UPDATE. cmd =", docmd)
|
log.Info("CAN NOT SELF UPDATE. cmd =", docmd)
|
||||||
log.Info("go get must be run from somewhere else other than startRepo")
|
log.Info("go get must be run from somewhere else other than startRepo")
|
||||||
log.Info("chdir to autotypist if it exists")
|
log.Info("chdir to autotypist if it exists")
|
||||||
msg := fmt.Sprint("CAN NOT SELF UPDATE. cmd =", docmd)
|
os.Exit(-1)
|
||||||
badExit(errors.New(msg))
|
|
||||||
}
|
}
|
||||||
// publish go.mod & go.sum for use with go
|
// publish go.mod & go.sum for use with go
|
||||||
os.Unsetenv("GO111MODULE")
|
os.Unsetenv("GO111MODULE")
|
||||||
log.Info("TRYING TO SELF UPDATE HERE. cmd =", docmd)
|
log.Info("TRYING TO SELF UPDATE HERE. cmd =", docmd)
|
||||||
result := me.startRepo.Run(docmd)
|
result = me.startRepo.Run(docmd)
|
||||||
|
|
||||||
if result.Error != nil {
|
if result.Error != nil {
|
||||||
log.Info("SELF UPDATE FAILED. error =", result.Error)
|
log.Info("SELF UPDATE FAILED. error =", result.Error)
|
||||||
|
|
19
exit.go
19
exit.go
|
@ -1,19 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.wit.com/log"
|
|
||||||
)
|
|
||||||
|
|
||||||
func okExit(thing string) {
|
|
||||||
log.Info(thing, "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.Config.ReposDir)
|
|
||||||
os.Exit(-1)
|
|
||||||
}
|
|
246
findNext.go
246
findNext.go
|
@ -1,13 +1,10 @@
|
||||||
|
// This is a simple example
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
"path/filepath"
|
|
||||||
|
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
|
|
||||||
|
"go.wit.com/lib/gui/repolist"
|
||||||
"go.wit.com/lib/protobuf/gitpb"
|
"go.wit.com/lib/protobuf/gitpb"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -15,153 +12,164 @@ var findCounter int
|
||||||
var findFix bool = false
|
var findFix bool = false
|
||||||
var findOk bool = true
|
var findOk bool = true
|
||||||
|
|
||||||
func checkDeps(repo *gitpb.Repo) error {
|
|
||||||
if repo.GoDeps == nil {
|
|
||||||
return fmt.Errorf("%s has GoDeps == nil", repo.GetNamespace())
|
|
||||||
}
|
|
||||||
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.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.GetNamespace() == check.GetNamespace() {
|
|
||||||
// this package is waiting on other packages to publish
|
|
||||||
return fmt.Errorf("%s is waiting on %s", repo.GetNamespace(), found.GetNamespace())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// found package isn't being published. is the version correct?
|
|
||||||
// never check this? we are done?
|
|
||||||
/*
|
|
||||||
if found.GetLastTag() == dep.Version {
|
|
||||||
// everything is normal
|
|
||||||
} else {
|
|
||||||
return fmt.Errorf("%s version mismatch on %s (%s vs %s)", repo.GetNamespace(), found.GetNamespace(), found.GetLastTag(), dep.Version)
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
// everything might be cool?
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// trys to figure out if there is still something to update
|
// trys to figure out if there is still something to update
|
||||||
// todo: redo this logic as it is terrible
|
// todo: redo this logic as it is terrible
|
||||||
// rename this findNext()
|
// rename this findNext()
|
||||||
func findNext() bool {
|
func findNext() bool {
|
||||||
findCounter = 0
|
findCounter = 0
|
||||||
all := me.found.SortByFullPath()
|
loop := me.repos.View.ReposSortByName()
|
||||||
for all.Scan() {
|
for loop.Scan() {
|
||||||
check := all.Next()
|
repo := loop.Repo()
|
||||||
if check.GetMasterBranchName() != check.GetCurrentBranchName() {
|
|
||||||
log.Info("YOU MUST BE ON THE MASTER BRANCH", check.GetNamespace())
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if check.IsDirty() {
|
|
||||||
log.Info("CAN NOT RELEASE DIRTY REPO", check.GetNamespace())
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if alreadyDone(check) {
|
|
||||||
log.Info("findNext() alreadyDone. WHY IS THIS STILL CHECKING?", check.GetNamespace())
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
log.Info("CHECKING START:", check.GetNamespace())
|
|
||||||
|
|
||||||
if me.forge.Config.IsPrivate(check.GetNamespace()) {
|
check := me.forge.Repos.FindByGoPath(repo.GoPath())
|
||||||
log.Info("GOOD TO GO ON PRIVATE REPO", check.GetNamespace())
|
if check == nil {
|
||||||
setCurrentRepo(check, "should be good to release", "pretty sure")
|
log.Info("boo, you didn't git clone", repo.GoPath())
|
||||||
return true
|
return false
|
||||||
}
|
}
|
||||||
|
if check.GetTargetVersion() == check.GetCurrentBranchVersion() {
|
||||||
godepsNew, err := check.GoSumFromRepo()
|
// log.Info("findNext() no update needed", check.GoPath, check.GetTargetVersion(), "vs", check.GetCurrentBranchVersion())
|
||||||
if err != nil {
|
|
||||||
log.Info("CHECKING go deps from repo failed", err)
|
|
||||||
continue
|
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 {
|
} else {
|
||||||
if err := testGoDepsCheckOk(godepsNew, argv.Verbose); err != nil {
|
log.Info("findNext() update needed", check.GoPath, check.GetTargetVersion(), "vs", check.GetCurrentBranchVersion())
|
||||||
log.Info("CHECKING current repo deps failed", err)
|
}
|
||||||
|
if me.forge.Config.IsReadOnly(check.GoPath) {
|
||||||
|
log.Info("findNext() skipping readonly")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if check.CheckDirty() {
|
||||||
|
log.Info("findNext() skipping dirty")
|
||||||
|
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 err := me.forge.FinalGoDepsCheckOk(check, argv.Verbose); err != nil {
|
}
|
||||||
// if err := me.forge.FinalGoDepsCheckOk(check, false); err != nil {
|
findCounter += 1
|
||||||
log.Info("FinalGoDepsCheckOk() repo=", check.GetNamespace(), "err:", err)
|
if check.Exists("go.mod") {
|
||||||
log.Info("CHECKING END:", check.GetNamespace())
|
log.Info("go.mod exists here")
|
||||||
log.Info("")
|
} else {
|
||||||
|
log.Info("go.mod is gone here")
|
||||||
|
}
|
||||||
|
if ok, err := check.ParseGoSum(); !ok {
|
||||||
|
log.Info("ParseGoSum() failed (probably repo needs go mod tidy)", err)
|
||||||
|
log.Info("ParseGoSum() findFix =", findFix, "findCounter =", findCounter)
|
||||||
|
if check.Exists("go.mod") {
|
||||||
|
log.Info("go.mod exists here")
|
||||||
|
} else {
|
||||||
|
log.Info("go.mod is gone here")
|
||||||
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
log.Info("GOOD TO GO ON", check.GetNamespace())
|
if check.Exists("go.mod") {
|
||||||
setCurrentRepo(check, "should be good to release", "pretty sure")
|
log.Info("go.mod exists here")
|
||||||
|
} else {
|
||||||
|
log.Info("go.mod is gone here")
|
||||||
|
}
|
||||||
|
if me.forge.FinalGoDepsCheckOk(check) {
|
||||||
|
setCurrentRepo(repo, "should be good to release", "pretty sure")
|
||||||
|
if check.Exists("go.mod") {
|
||||||
|
log.Info("go.mod exists here")
|
||||||
|
} else {
|
||||||
|
log.Info("go.mod is gone here")
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
if check.Exists("go.mod") {
|
||||||
|
log.Info("go.mod exists here")
|
||||||
|
} else {
|
||||||
|
log.Info("go.mod is gone here")
|
||||||
|
}
|
||||||
|
log.Info("findNext() got to the end. repo", repo.GoPath(), "did not work. trying to find a new one now")
|
||||||
|
}
|
||||||
if findCounter == 0 {
|
if findCounter == 0 {
|
||||||
log.Info("NOTHING TO UPDATE. findCounter =", findCounter, "found len =", me.found.Len())
|
log.Info("NOTHING TO UPDATE. findCounter =", findCounter)
|
||||||
if me.found.Len() == 0 {
|
|
||||||
printDone()
|
|
||||||
okExit("")
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
|
findFix = true
|
||||||
log.Info("me.current is nil findCounter =", findCounter, "so set findFix =", findFix)
|
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)
|
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?")
|
me.release.status.SetText("ALL DONE?")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func setCurrentRepo(check *gitpb.Repo, s string, note string) bool {
|
func runGoClean(check *gitpb.Repo) bool {
|
||||||
me.current = check
|
// check if the package dependancies changed, if so, re-publish
|
||||||
if check == nil {
|
check.GoDeps = nil
|
||||||
me.release.repo.SetText("")
|
|
||||||
me.release.version.SetText("")
|
cmd := []string{"go-mod-clean"}
|
||||||
me.release.releaseVersionB.SetText("nope")
|
log.Info("Running", cmd, "in", check.GoPath)
|
||||||
me.release.version.SetText("badver")
|
result := check.RunRealtime(cmd)
|
||||||
} else {
|
if result.Error != nil {
|
||||||
me.release.repo.SetText(check.GetNamespace())
|
log.Info(cmd, "failed with", result.Error, check.GoPath)
|
||||||
me.release.version.SetText(check.GetTargetVersion())
|
return false
|
||||||
me.release.releaseVersionB.SetText("release version " + check.GetTargetVersion())
|
}
|
||||||
me.release.version.SetText(check.GetTargetVersion())
|
if result.Exit != 0 {
|
||||||
|
log.Info(cmd, "failed with", result.Exit, check.GoPath)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if ok, err := check.ParseGoSum(); !ok {
|
||||||
|
log.Info("ParseGoSum() failed", err)
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
me.release.status.SetText(s)
|
|
||||||
me.release.notes.SetText(note)
|
|
||||||
// me.release.openrepo.Enable()
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func testGoDepsCheckOk(godeps *gitpb.GoDeps, verbose bool) error {
|
// tries to fix the go.mod and go.sum files
|
||||||
if godeps == nil {
|
func fixGodeps(check *gitpb.Repo) bool {
|
||||||
return errors.New("testGoDepsCheckOk() godeps == nil")
|
var good bool = true
|
||||||
|
if !runGoClean(check) {
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
all := godeps.SortByGoPath()
|
// skip primative ones
|
||||||
for all.Scan() {
|
if ok, _ := check.IsPrimitive(); ok {
|
||||||
depRepo := all.Next()
|
log.Info("fixGoDeps() skipping primitive", check.GoPath)
|
||||||
fullpath := filepath.Join(me.forge.Config.ReposDir, depRepo.GoPath)
|
return true
|
||||||
found := me.found.FindByFullPath(fullpath)
|
}
|
||||||
|
log.Printf("current repo %s go dependancy count: %d", 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.GoPath) {
|
||||||
|
log.Info("IsReadOnly = true", depRepo.GetGoPath())
|
||||||
|
continue
|
||||||
|
} else {
|
||||||
|
// log.Info("IsReadOnly = false", depRepo.GetGoPath())
|
||||||
|
}
|
||||||
|
found := me.forge.Repos.FindByGoPath(depRepo.GetGoPath())
|
||||||
if found == nil {
|
if found == nil {
|
||||||
|
log.Info("not found:", depRepo.GetGoPath())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
return fmt.Errorf("dep is being upgraded %s", depRepo.GoPath)
|
if depRepo.GetVersion() != found.GetMasterVersion() {
|
||||||
|
log.Printf("%-48s %10s (gitpb depRepo)", depRepo.GetGoPath(), depRepo.GetVersion())
|
||||||
|
log.Printf("%-48s %10s (gitpb found)", found.GetGoPath(), found.GetMasterVersion())
|
||||||
|
cmd := []string{"go", "get", depRepo.GetGoPath() + "@latest"}
|
||||||
|
check.Run(cmd)
|
||||||
}
|
}
|
||||||
return nil
|
}
|
||||||
|
return good
|
||||||
|
}
|
||||||
|
|
||||||
|
func setCurrentRepo(repo *repolist.RepoRow, s string, note string) bool {
|
||||||
|
check := me.forge.Repos.FindByGoPath(repo.GoPath())
|
||||||
|
if check == nil {
|
||||||
|
log.Info("boo, you didn't git clone", repo.GoPath())
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
me.release.repo.SetText(check.GoPath)
|
||||||
|
me.release.status.SetText(s)
|
||||||
|
me.release.notes.SetText(note)
|
||||||
|
me.current = repo
|
||||||
|
me.release.version.SetText(check.GetTargetVersion())
|
||||||
|
me.release.releaseVersionB.SetText("release version " + check.GetTargetVersion())
|
||||||
|
me.release.openrepo.Enable()
|
||||||
|
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"go.wit.com/gui"
|
"go.wit.com/gui"
|
||||||
"go.wit.com/lib/debugger"
|
"go.wit.com/lib/debugger"
|
||||||
"go.wit.com/lib/gui/logsettings"
|
"go.wit.com/lib/gui/logsettings"
|
||||||
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func globalDisplayOptions(box *gui.Node) {
|
func globalDisplayOptions(box *gui.Node) {
|
||||||
|
@ -11,8 +12,8 @@ func globalDisplayOptions(box *gui.Node) {
|
||||||
|
|
||||||
group1 := vbox.NewGroup("Global Display Options")
|
group1 := vbox.NewGroup("Global Display Options")
|
||||||
|
|
||||||
/*
|
|
||||||
hidegrid := group1.NewGrid("hidecfg", 0, 0)
|
hidegrid := group1.NewGrid("hidecfg", 0, 0)
|
||||||
|
|
||||||
hidegrid.NewButton("Show Repository Window", func() {
|
hidegrid.NewButton("Show Repository Window", func() {
|
||||||
if me.repos.Hidden() {
|
if me.repos.Hidden() {
|
||||||
me.repos.Show()
|
me.repos.Show()
|
||||||
|
@ -22,13 +23,12 @@ func globalDisplayOptions(box *gui.Node) {
|
||||||
log.Info("showing reposwin")
|
log.Info("showing reposwin")
|
||||||
})
|
})
|
||||||
hidegrid.NextRow()
|
hidegrid.NextRow()
|
||||||
*/
|
|
||||||
|
|
||||||
group1 = vbox.NewGroup("prep for release")
|
group1 = vbox.NewGroup("prep for release")
|
||||||
grid := group1.RawGrid()
|
grid := group1.RawGrid()
|
||||||
|
|
||||||
grid.NewButton("make prepare-release", func() {
|
grid.NewButton("make prepare-release", func() {
|
||||||
rePrepareRelease()
|
makePrepareRelease()
|
||||||
})
|
})
|
||||||
grid.NextRow()
|
grid.NextRow()
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"go.wit.com/lib/gui/repolist"
|
||||||
|
)
|
||||||
|
|
||||||
|
// like tcl/tk, use ENV variables to set display preferences
|
||||||
|
func hideFunction(r *repolist.RepoRow) {
|
||||||
|
// always show dirty repos
|
||||||
|
if r.Status.IsDirty() {
|
||||||
|
r.Show()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// hide read-only repos
|
||||||
|
if os.Getenv("AUTOTYPIST_READONLY") == "hide" {
|
||||||
|
if r.Status.ReadOnly() {
|
||||||
|
// log.Info(r.Name(), "hiding read-only repo")
|
||||||
|
r.Hide()
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
// log.Info(r.Name(), "not hiding read-only repo")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// show repos with mismatched mode
|
||||||
|
// this means, if you are in "devel" mode, show all the repos that
|
||||||
|
// might be stuck on the wrong branch, like 'master' or '<username>'
|
||||||
|
if os.Getenv("AUTOTYPIST_MODE") != "" {
|
||||||
|
if !r.Status.IsCorrectMode(os.Getenv("AUTOTYPIST_MODE")) {
|
||||||
|
r.Show()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// show everything else. often this will be "unconforming" repos
|
||||||
|
// if you what those repos ignored, add these to the config file
|
||||||
|
// as read-only=true
|
||||||
|
r.Show()
|
||||||
|
}
|
238
http.go
238
http.go
|
@ -7,7 +7,7 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"go.wit.com/lib/protobuf/gitpb"
|
"go.wit.com/lib/gui/repolist"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -27,6 +27,10 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
repoName := r.URL.Query().Get("repo")
|
repoName := r.URL.Query().Get("repo")
|
||||||
version := r.URL.Query().Get("version")
|
version := r.URL.Query().Get("version")
|
||||||
comment := r.URL.Query().Get("comment")
|
comment := r.URL.Query().Get("comment")
|
||||||
|
readonly := r.URL.Query().Get("readonly")
|
||||||
|
onlydirty := r.URL.Query().Get("onlydirty")
|
||||||
|
perfect := r.URL.Query().Get("perfect")
|
||||||
|
whitelist := r.URL.Query().Get("whitelist")
|
||||||
|
|
||||||
switch route {
|
switch route {
|
||||||
case "/help":
|
case "/help":
|
||||||
|
@ -46,7 +50,7 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
log.Info("")
|
log.Info("")
|
||||||
case "/doRelease":
|
case "/doRelease":
|
||||||
buttonDisable()
|
buttonDisable()
|
||||||
if err := doRelease(); err == nil {
|
if doRelease() {
|
||||||
buttonEnable()
|
buttonEnable()
|
||||||
log.Info("doRelease() worked")
|
log.Info("doRelease() worked")
|
||||||
} else {
|
} else {
|
||||||
|
@ -70,54 +74,149 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// log.Info(me.current.StandardHeader())
|
log.Info(me.current.StandardHeader())
|
||||||
log.Info(me.forge.StandardReleaseHeader(me.current, "todoing"))
|
log.Info(me.current.StandardReleaseHeader())
|
||||||
|
case "/rescanAll":
|
||||||
|
me.repos.View.ScanRepositories()
|
||||||
case "/setCurrentRepo":
|
case "/setCurrentRepo":
|
||||||
|
|
||||||
log.Info("repo: " + repoName)
|
log.Info("repo: " + repoName)
|
||||||
log.Info("version: " + version)
|
log.Info("version: " + version)
|
||||||
log.Info("comment: " + comment)
|
log.Info("comment: " + comment)
|
||||||
|
|
||||||
repo := me.forge.FindByGoPath(repoName)
|
repo := me.repos.View.FindByName(repoName)
|
||||||
if repo == nil {
|
if repo == nil {
|
||||||
log.Info("FindRepoByName() returned nil")
|
log.Info("FindRepoByName() returned nil")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
setCurrentRepo(repo, "HTTP", "doRelease() ?")
|
setCurrentRepo(repo, "HTTP", "doRelease() ?")
|
||||||
|
case "/IncrementRevisonVersion":
|
||||||
|
log.Info("repo: " + repoName)
|
||||||
|
log.Info("version: " + version)
|
||||||
|
me.current.Status.IncrementRevisionVersion(comment)
|
||||||
|
case "/IncrementMinorVersion":
|
||||||
|
log.Info("repo: " + repoName)
|
||||||
|
log.Info("version: " + version)
|
||||||
|
|
||||||
|
me.current.Status.IncrementMinorVersion("trying minor")
|
||||||
|
case "/setAllBranchesToMaster":
|
||||||
|
log.Info("set all branches to master")
|
||||||
|
me.Disable()
|
||||||
|
defer me.Enable()
|
||||||
|
if setAllBranchesToMaster() {
|
||||||
|
// if it succeeds, disable this button
|
||||||
|
me.setBranchesToMasterB.Disable()
|
||||||
|
}
|
||||||
return
|
return
|
||||||
case "/showNext":
|
case "/setTargetVersion":
|
||||||
check := me.forge.FindByGoPath(me.current.GetGoPath())
|
log.Info("repo: " + repoName)
|
||||||
if check == nil {
|
log.Info("version: " + version)
|
||||||
log.Info("boo, current is missing", me.current.GetGoPath())
|
if repoName != "" {
|
||||||
|
repo := me.repos.View.FindByName(repoName)
|
||||||
|
if repo == nil {
|
||||||
|
log.Info("could not find repo", repoName)
|
||||||
|
} else {
|
||||||
|
log.Info("setting target version", version)
|
||||||
|
repo.Status.SetTargetVersion(version)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
testGoRepo(check)
|
|
||||||
me.forge.HumanPrintRepo(check)
|
if me.current == nil {
|
||||||
log.Info("upgrade reason:", me.reason[check])
|
log.Info("me.current == nil")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
me.current.Status.SetTargetVersion(version)
|
||||||
|
return
|
||||||
|
case "/setAllTargetVersions":
|
||||||
|
log.Info("version: " + version)
|
||||||
|
|
||||||
|
loop := me.repos.View.ReposSortByName()
|
||||||
|
for loop.Scan() {
|
||||||
|
repo := loop.Repo()
|
||||||
|
|
||||||
|
master := repo.Status.GetMasterVersion()
|
||||||
|
lastTag := repo.Status.LastTag()
|
||||||
|
if master == lastTag {
|
||||||
|
repo.Status.SetTargetVersion(master)
|
||||||
|
} else {
|
||||||
|
repo.Status.IncrementRevisionVersion("Nov 2024 test")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case "/whitelist":
|
||||||
|
repo := me.repos.View.FindByName(repoName)
|
||||||
|
if repo == nil {
|
||||||
|
log.Info("FindRepoByName() returned nil")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
log.Info("whitelisted " + repo.Name())
|
||||||
|
if whitelist == "false" {
|
||||||
|
repo.Status.Whitelist = false
|
||||||
|
} else {
|
||||||
|
repo.Status.Whitelist = true
|
||||||
|
}
|
||||||
|
case "/testNext":
|
||||||
|
testNext()
|
||||||
|
return
|
||||||
|
case "/fixNext":
|
||||||
|
check := me.forge.Repos.FindByGoPath(me.current.GoPath())
|
||||||
|
if check == nil {
|
||||||
|
log.Info("boo, you didn't git clone", me.current.GoPath())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// destroy and recreate the go.sum
|
||||||
|
fixGodeps(check)
|
||||||
|
findOk = true
|
||||||
|
return
|
||||||
|
case "/showNext":
|
||||||
|
showNext()
|
||||||
return
|
return
|
||||||
case "/list":
|
case "/list":
|
||||||
me.forge.PrintHumanTable(me.found)
|
PrintReport(readonly, onlydirty, perfect)
|
||||||
return
|
return
|
||||||
case "/releaseList":
|
case "/releaseList":
|
||||||
me.forge.PrintHumanTable(me.found)
|
PrintReleaseReport(readonly, perfect)
|
||||||
|
return
|
||||||
|
case "/quit":
|
||||||
|
log.Info("Got URL /quit")
|
||||||
|
os.Exit(0)
|
||||||
|
return
|
||||||
|
case "/goweblist":
|
||||||
|
loop := me.repos.View.ReposAll()
|
||||||
|
for loop.Scan() {
|
||||||
|
repo := loop.Repo()
|
||||||
|
|
||||||
|
lastTag := repo.LastTag()
|
||||||
|
tag := repo.Status.NewestTag()
|
||||||
|
gitAge, err := tag.GetDate()
|
||||||
|
if err != nil {
|
||||||
|
log.Info(fmt.Sprintf("tag date error", repo.Name()))
|
||||||
|
}
|
||||||
|
// if lastTag == "" {
|
||||||
|
// lastTag = tag.Name()
|
||||||
|
// }
|
||||||
|
if repo.ReadOnly() {
|
||||||
|
if readonly == "true" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// dur := time.Since(gitAge)
|
||||||
|
// log.Info(fmt.Sprintf("%-60s %s %s %s", repo.Name(), lastTag, shell.FormatDuration(dur), lastTag, tag.Name()))
|
||||||
|
log.Info(fmt.Sprintf("%s %d %s", repo.Name(), gitAge.Unix(), lastTag))
|
||||||
|
/*
|
||||||
|
for _, tag := range repo.Tags.ListAll() {
|
||||||
|
log.Info(fmt.Sprintf("%-60s %s", "", tag.Name()))
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
}
|
||||||
return
|
return
|
||||||
default:
|
default:
|
||||||
log.Info("BAD URL = " + route)
|
log.Info("BAD URL = " + route)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testGoRepo(check *gitpb.Repo) {
|
|
||||||
data, _ := os.ReadFile(filepath.Join(check.FullPath, "go.mod"))
|
|
||||||
log.Info(string(data))
|
|
||||||
|
|
||||||
if err := me.forge.FinalGoDepsCheckOk(check, true); err == nil {
|
|
||||||
log.Info("forge.FinalGoDepsCheck(check) worked!")
|
|
||||||
} else {
|
|
||||||
log.Info("forge.FinalGoDepsCheck(check) failed. boo.")
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// starts and sits waiting for HTTP requests
|
// starts and sits waiting for HTTP requests
|
||||||
func startHTTP() {
|
func startHTTP() {
|
||||||
http.HandleFunc("/", okHandler)
|
http.HandleFunc("/", okHandler)
|
||||||
|
@ -130,3 +229,90 @@ func startHTTP() {
|
||||||
log.Println("Error starting server:", err)
|
log.Println("Error starting server:", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func testNext() {
|
||||||
|
// re-scans the go.sum file. DOES NOT MODIFY ANYTHING
|
||||||
|
check := me.forge.Repos.FindByGoPath(me.current.GoPath())
|
||||||
|
if check == nil {
|
||||||
|
log.Info("boo, you didn't git clone", me.current.GoPath())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
data, _ := os.ReadFile(filepath.Join(check.FullPath, "go.mod"))
|
||||||
|
log.Info(string(data))
|
||||||
|
|
||||||
|
if me.forge.FinalGoDepsCheckOk(check) {
|
||||||
|
log.Info("forge.FinalGoDepsCheck(check) worked!")
|
||||||
|
} else {
|
||||||
|
log.Info("forge.FinalGoDepsCheck(check) failed. boo.")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func showNext() {
|
||||||
|
log.Info("gui repo: " + me.release.repo.String())
|
||||||
|
log.Info("gui name: " + me.release.version.String())
|
||||||
|
log.Info("gui notes: " + me.release.notes.String())
|
||||||
|
log.Info("gui status: " + me.release.status.String())
|
||||||
|
log.Info("")
|
||||||
|
if me.current == nil {
|
||||||
|
log.Info("me.current == nil")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
check := me.forge.Repos.FindByGoPath(me.current.GoPath())
|
||||||
|
if check == nil {
|
||||||
|
log.Info("forge: how was this not found?", me.current.GoPath())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if me.current.Status.IsReleased() {
|
||||||
|
log.Info("IsReleased() == true. do not release this a second time")
|
||||||
|
} else {
|
||||||
|
log.Info("IsReleased() == false")
|
||||||
|
}
|
||||||
|
if check.CheckDirty() {
|
||||||
|
log.Info("CheckDirty() == true. do not release dirty repos")
|
||||||
|
} else {
|
||||||
|
log.Info("CheckDirty() == false")
|
||||||
|
}
|
||||||
|
if ok, _ := check.IsPrimitive(); ok {
|
||||||
|
log.Info("IsPrimitive() == true")
|
||||||
|
} else {
|
||||||
|
log.Info("IsPrimitive() == false")
|
||||||
|
}
|
||||||
|
if me.forge.Config.IsPrivate(check.GoPath) {
|
||||||
|
log.Info("IsPrivate() == true")
|
||||||
|
} else {
|
||||||
|
log.Info("IsPrivate() == false")
|
||||||
|
}
|
||||||
|
if ok, compiled, err := me.current.IsProtobuf(); ok {
|
||||||
|
log.Info(log.Sprint("IsProtobuf() == true compiled protobuf files = ", compiled))
|
||||||
|
if err != nil {
|
||||||
|
log.Info(log.Sprint("IsProtobuf() == err", err))
|
||||||
|
os.Exit(-1)
|
||||||
|
}
|
||||||
|
for _, s := range compiled {
|
||||||
|
log.Info("\tcompiled file found:", s)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log.Info("IsProtobuf() == false")
|
||||||
|
if err != nil {
|
||||||
|
log.Info(log.Sprint("IsProtobuf() == err", err))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if me.current.Status.Whitelist {
|
||||||
|
log.Info("Whitelist == true SHOULD NOT RELEASE THIS")
|
||||||
|
} else {
|
||||||
|
log.Info("Whitelist == false")
|
||||||
|
}
|
||||||
|
log.Info("")
|
||||||
|
|
||||||
|
testNext()
|
||||||
|
|
||||||
|
log.Info(repolist.ReportHeader())
|
||||||
|
log.Info(me.current.StandardHeader())
|
||||||
|
log.Info("")
|
||||||
|
log.Info(repolist.ReleaseReportHeader())
|
||||||
|
log.Info(me.current.StandardReleaseHeader())
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,85 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"go.wit.com/lib/gui/repolist"
|
||||||
|
"go.wit.com/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
func PrintReport(readonly string, onlydirty string, perfect string) {
|
||||||
|
var count int
|
||||||
|
|
||||||
|
log.Info(repolist.ReportHeader())
|
||||||
|
|
||||||
|
loop := me.repos.View.ReposSortByName()
|
||||||
|
for loop.Scan() {
|
||||||
|
repo := loop.Repo()
|
||||||
|
|
||||||
|
count += 1
|
||||||
|
header := repo.StandardHeader()
|
||||||
|
if onlydirty == "true" {
|
||||||
|
if repo.CheckDirty() {
|
||||||
|
log.Info(header + "")
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if me.forge.Config.IsReadOnly(repo.GoPath()) {
|
||||||
|
if readonly == "true" {
|
||||||
|
log.Info(header + "readonly")
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if repo.State() == "PERFECT" {
|
||||||
|
if perfect == "false" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if repo.State() != "merge to main" {
|
||||||
|
log.Info(header + "")
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if repo.CheckDirty() {
|
||||||
|
log.Info(header + "")
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
log.Info(header + "")
|
||||||
|
check := me.forge.Repos.FindByGoPath(repo.GoPath())
|
||||||
|
if check == nil {
|
||||||
|
log.Info("boo, you didn't git clone", repo.GoPath())
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
me.forge.StandardReleaseHeader(check, repo.State())
|
||||||
|
}
|
||||||
|
log.Info(fmt.Sprintf("EVERYTHING WORKED repo count = %d", count))
|
||||||
|
}
|
||||||
|
|
||||||
|
func PrintReleaseReport(readonly string, perfect string) int {
|
||||||
|
var count int
|
||||||
|
|
||||||
|
log.Info(repolist.ReleaseReportHeader())
|
||||||
|
|
||||||
|
loop := me.forge.Repos.SortByGoPath()
|
||||||
|
for loop.Scan() {
|
||||||
|
check := loop.Next()
|
||||||
|
if me.forge.Config.IsReadOnly(check.GoPath) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if check.GetCurrentBranchVersion() == check.GetTargetVersion() {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
count += 1
|
||||||
|
if check == nil {
|
||||||
|
log.Info("boo, you didn't git clone", check.GoPath)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
var state string
|
||||||
|
if check.CheckDirty() {
|
||||||
|
state = "(dirty)"
|
||||||
|
}
|
||||||
|
log.Info(me.forge.StandardReleaseHeader(check, state))
|
||||||
|
}
|
||||||
|
log.Info(fmt.Sprintf("total repo count = %d", count))
|
||||||
|
return count
|
||||||
|
}
|
149
main.go
149
main.go
|
@ -2,23 +2,18 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"embed"
|
"embed"
|
||||||
"errors"
|
|
||||||
"fmt"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"go.wit.com/dev/alexflint/arg"
|
"go.wit.com/dev/alexflint/arg"
|
||||||
"go.wit.com/lib/fhelp"
|
"go.wit.com/gui"
|
||||||
"go.wit.com/lib/gadgets"
|
|
||||||
"go.wit.com/lib/gui/prep"
|
|
||||||
"go.wit.com/lib/gui/shell"
|
"go.wit.com/lib/gui/shell"
|
||||||
"go.wit.com/lib/protobuf/forgepb"
|
"go.wit.com/lib/protobuf/forgepb"
|
||||||
"go.wit.com/lib/protobuf/gitpb"
|
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
var VERSION string
|
var VERSION string
|
||||||
var ARGNAME string = "guireleaser"
|
|
||||||
|
|
||||||
//go:embed resources/*
|
//go:embed resources/*
|
||||||
var resources embed.FS
|
var resources embed.FS
|
||||||
|
@ -27,24 +22,21 @@ var argv args
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
me = new(autoType)
|
me = new(autoType)
|
||||||
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)
|
|
||||||
|
|
||||||
|
// load the ~/.config/forge/ config
|
||||||
me.forge = forgepb.Init()
|
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()
|
// me.forge.ConfigPrintTable()
|
||||||
os.Setenv("REPO_WORK_PATH", me.forge.Config.ReposDir)
|
os.Setenv("REPO_WORK_PATH", me.forge.GetGoSrc())
|
||||||
|
|
||||||
|
// parse the command line
|
||||||
|
arg.MustParse(&argv)
|
||||||
|
|
||||||
// save the ENV var here
|
// save the ENV var here
|
||||||
me.releaseReasonS = os.Getenv("GUIRELEASE_REASON")
|
me.releaseReasonS = os.Getenv("GUIRELEASE_REASON")
|
||||||
|
|
||||||
if me.releaseReasonS == "" {
|
if me.releaseReasonS == "" {
|
||||||
badExit(errors.New("shell ENV GUIRELEASE_REASON not set"))
|
log.Info("shell ENV GUIRELEASE_REASON not set")
|
||||||
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// unset the go development ENV var to generate release files
|
// unset the go development ENV var to generate release files
|
||||||
|
@ -52,20 +44,16 @@ func main() {
|
||||||
// user drops to a shell or xterm, then they shouldn't be set there either
|
// user drops to a shell or xterm, then they shouldn't be set there either
|
||||||
os.Unsetenv("GO111MODULE")
|
os.Unsetenv("GO111MODULE")
|
||||||
|
|
||||||
me.myGui.Start() // loads the GUI toolkit
|
me.myGui = gui.New()
|
||||||
|
me.myGui.InitEmbed(resources)
|
||||||
|
me.myGui.Default()
|
||||||
|
|
||||||
// our main window
|
// our main window
|
||||||
me.mainWindow = gadgets.RawBasicWindow("GUI release manager " + VERSION)
|
me.mainWindow = me.myGui.NewWindow("GUI release manager " + VERSION)
|
||||||
me.mainWindow.Custom = func() {
|
me.mainBox = me.mainWindow.NewBox("bw hbox", true)
|
||||||
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()
|
|
||||||
|
|
||||||
me.mainBox = me.mainWindow.Box()
|
// start the http server for polling status
|
||||||
|
go startHTTP()
|
||||||
|
|
||||||
// sanity check of things that might be around that mess
|
// sanity check of things that might be around that mess
|
||||||
// up things later
|
// up things later
|
||||||
|
@ -74,58 +62,101 @@ func main() {
|
||||||
homeDir, _ := os.UserHomeDir()
|
homeDir, _ := os.UserHomeDir()
|
||||||
gowork := filepath.Join(homeDir, "go/src/go.work")
|
gowork := filepath.Join(homeDir, "go/src/go.work")
|
||||||
if shell.Exists(gowork) {
|
if shell.Exists(gowork) {
|
||||||
badExit(errors.New("go.work must be deleted"))
|
log.Info("go.work must be deleted")
|
||||||
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Info("Creating the Release Window")
|
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
|
// the left side of the window options
|
||||||
globalDisplayOptions(me.mainBox)
|
globalDisplayOptions(me.mainBox)
|
||||||
|
|
||||||
// create the right side of the main window
|
// create the right side of the main window
|
||||||
createReleaseBox(me.mainBox)
|
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
|
// disable the gui until the repos are scanned
|
||||||
me.release.box.Disable()
|
me.release.box.Disable()
|
||||||
me.Disable()
|
me.Disable()
|
||||||
|
|
||||||
// todo: add this to forgepb
|
// register a Show/Hide function for the repo list table
|
||||||
me.startRepo = me.forge.FindWorkingDirRepo()
|
me.repos.View.RegisterHideFunction(hideFunction)
|
||||||
|
|
||||||
if _, count, _, err := me.forge.IsEverythingOnMaster(); err != nil {
|
// scan in the State of all the repos
|
||||||
log.Info("not everything is on the master branch (", count, "repos)")
|
// TODO: should not really be necessary directly after init()
|
||||||
if argv.Quick != nil {
|
me.repos.View.ScanRepositories()
|
||||||
// quick also means ignore the master branch check
|
|
||||||
argv.Force = true
|
loop := me.repos.View.ReposSortByName()
|
||||||
|
for loop.Scan() {
|
||||||
|
repo := loop.Repo()
|
||||||
|
if me.forge.Config.IsReadOnly(repo.GoPath()) {
|
||||||
|
repo.Status.SetReadOnly(true)
|
||||||
|
} else {
|
||||||
|
repo.Status.SetReadOnly(false)
|
||||||
}
|
}
|
||||||
if !argv.Force {
|
if me.forge.Config.IsPrivate(repo.GoPath()) {
|
||||||
os.Exit(-1)
|
repo.Status.SetPrivate(true)
|
||||||
|
} else {
|
||||||
|
repo.Status.SetPrivate(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pwd, _ := os.Getwd()
|
||||||
|
basedir := strings.TrimPrefix(pwd, me.forge.GetGoSrc())
|
||||||
|
basedir = strings.Trim(basedir, "/")
|
||||||
|
me.startRepo = me.forge.Repos.FindByGoPath(basedir)
|
||||||
|
|
||||||
if me.startRepo == nil {
|
if me.startRepo == nil {
|
||||||
pwd, _ := os.Getwd()
|
log.Info("Can not run if pwd is not a repo", basedir)
|
||||||
msg := fmt.Sprint("Can not run if pwd is not a repo", pwd)
|
os.Exit(0)
|
||||||
badExit(errors.New(msg))
|
|
||||||
}
|
|
||||||
|
|
||||||
me.forge.RillFuncError(rillPurge)
|
|
||||||
|
|
||||||
// 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.Enable()
|
||||||
me.release.box.Enable()
|
|
||||||
|
|
||||||
// start the http server for polling status
|
// set all branches to master & findNext()
|
||||||
startHTTP()
|
makePrepareRelease()
|
||||||
|
|
||||||
|
// 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()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// start the initail scan and make sure each repo is set
|
||||||
|
// to the master branch
|
||||||
|
func setAllBranchesToMaster() bool {
|
||||||
|
var worked bool = true
|
||||||
|
loop := me.repos.View.ReposSortByName()
|
||||||
|
for loop.Scan() {
|
||||||
|
repo := loop.Repo()
|
||||||
|
if repo.ReadOnly() {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if repo.IsDirty() {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if repo.Status.Whitelist {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if repo.Status.CheckoutMaster() {
|
||||||
|
log.Warn("git checkout master branch worked", repo.Name())
|
||||||
|
} else {
|
||||||
|
log.Warn("git checkout master branch failed", repo.Name())
|
||||||
|
worked = false
|
||||||
|
}
|
||||||
|
// repo.NewScan()
|
||||||
|
}
|
||||||
|
return worked
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,297 +1,102 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
"path/filepath"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"go.wit.com/lib/gui/shell"
|
|
||||||
"go.wit.com/lib/protobuf/forgepb"
|
|
||||||
"go.wit.com/lib/protobuf/gitpb"
|
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func forceReleaseVersion(repo *gitpb.Repo) {
|
func makePrepareRelease() {
|
||||||
if argv.Minor {
|
me.Disable()
|
||||||
// if v1.2.3 change to v.1.3.0
|
me.release.box.Disable()
|
||||||
repo.IncrementTargetMinor()
|
defer me.Enable()
|
||||||
|
|
||||||
|
if setAllBranchesToMaster() {
|
||||||
|
// if it succeeds, disable this button
|
||||||
|
me.setBranchesToMasterB.Disable()
|
||||||
|
me.release.box.Enable()
|
||||||
|
PrintReleaseReport("", "")
|
||||||
} else {
|
} else {
|
||||||
// if v1.2.3 change to v.1.2.4
|
log.Info("setAllBranchesToMaster() failed")
|
||||||
repo.IncrementTargetRevision()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkpkgcache(repo *gitpb.Repo) error {
|
// reset all the target versions back to the current version
|
||||||
homedir, err := os.UserHomeDir()
|
// incase they were saved in the repos.pb file
|
||||||
if err != nil {
|
all := me.forge.Repos.SortByGoPath()
|
||||||
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()
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
_, 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() {
|
|
||||||
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)
|
|
||||||
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() {
|
for all.Scan() {
|
||||||
check := all.Next()
|
check := all.Next()
|
||||||
|
|
||||||
if alreadyDone(check) {
|
// set the target version to the current master version
|
||||||
// means it was already published
|
curver := check.GetMasterVersion()
|
||||||
// protects against logic errors that might result
|
check.SetTargetVersion(curver)
|
||||||
// in an infinite loop
|
|
||||||
log.Info("WARNING alreadyDone rePrepareRelease()", check.GetGoPath())
|
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if me.forge.Config.IsReadOnly(check.GetGoPath()) {
|
// run go-mod-clean on everything not readonly
|
||||||
|
all = me.forge.Repos.SortByGoPath()
|
||||||
|
for all.Scan() {
|
||||||
|
check := all.Next()
|
||||||
|
|
||||||
|
if me.forge.Config.IsReadOnly(check.GoPath) {
|
||||||
// can't release readonly repos
|
// can't release readonly repos
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ok, err := check.IsPrimitive(); !ok {
|
||||||
|
log.Info("something wrong with", check.GoPath, err)
|
||||||
|
// no go.sum file for these
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if check.Exists("go.sum") {
|
||||||
|
// probably already ran
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if !runGoClean(check) {
|
||||||
|
log.Info("go-mod-clean FAILED. THIS IS BAD.", check.GoPath)
|
||||||
|
log.Info("go-mod-clean FAILED. THIS IS BAD.", check.GoPath)
|
||||||
|
log.Info("go-mod-clean FAILED. THIS IS BAD.", check.GoPath)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
all = me.forge.Repos.SortByGoPath()
|
||||||
|
for all.Scan() {
|
||||||
|
check := all.Next()
|
||||||
|
|
||||||
|
if me.forge.Config.IsReadOnly(check.GoPath) {
|
||||||
|
// can't release readonly repos
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
// if master != lastTag, always increment
|
||||||
master := check.GetMasterVersion()
|
master := check.GetMasterVersion()
|
||||||
lastTag := check.GetLastTag()
|
lastTag := check.GetLastTag()
|
||||||
|
|
||||||
if argv.Quick != nil {
|
|
||||||
// if argv has 'quick' don't do anything
|
|
||||||
// that doesn't actually have a patch
|
|
||||||
if master == lastTag {
|
|
||||||
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 {
|
if master != lastTag {
|
||||||
newmhash := check.GetTagHash(master)
|
// if v1.2.3 change to v.1.2.4
|
||||||
oldlhash := check.GetTagHash(lastTag)
|
check.IncrementTargetRevision()
|
||||||
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
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if me.forge.Config.IsPrivate(check.GetGoPath()) {
|
// if the repo is a go binary, try forcing new go.* files
|
||||||
// only checks after this are GO dep related which don't matter for private repos
|
if check.RepoType() == "binary" {
|
||||||
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.AppendByFullPath(check)
|
|
||||||
me.reason[check] = "protobuf repo deps changed"
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
// if the repo is a go binary or plugin for a new release for
|
|
||||||
// any library version change
|
|
||||||
// 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 err := me.forge.FinalGoDepsCheckOk(check, false); err == nil {
|
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())
|
||||||
continue
|
|
||||||
} else {
|
} else {
|
||||||
log.Printf("NEED RELEASE FOR %-50s err: %v\n", check.GetGoPath(), err)
|
log.Printf("dependancy checks indicate a new release is needed for %s\n", check.GetGoPath())
|
||||||
forceReleaseVersion(check)
|
// if v1.2.3 change to v.1.2.4
|
||||||
me.found.AppendByFullPath(check)
|
check.IncrementTargetRevision()
|
||||||
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.Info("printDone() total finished so far:", len(me.done))
|
if findNext() {
|
||||||
time.Sleep(time.Second)
|
log.Info("prepare release findNext() returned true")
|
||||||
}
|
me.release.box.Enable()
|
||||||
|
|
||||||
func alreadyDone(repo *gitpb.Repo) bool {
|
|
||||||
for _, gopath := range me.done {
|
|
||||||
// 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 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 {
|
} else {
|
||||||
return fmt.Errorf("published godeps == nil vs real != nil")
|
log.Info("prepare release findNext() returned false")
|
||||||
|
if findNext() {
|
||||||
|
log.Info("prepare release findNext() returned true")
|
||||||
|
me.release.box.Enable()
|
||||||
|
} else {
|
||||||
|
log.Info("prepare release findNext() returned false")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err := me.forge.TestGoDepsCheckOk(godepsNew, argv.Verbose); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
225
releaseBox.go
225
releaseBox.go
|
@ -3,14 +3,15 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"go.wit.com/gui"
|
"go.wit.com/gui"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
|
|
||||||
"go.wit.com/lib/gadgets"
|
"go.wit.com/lib/gadgets"
|
||||||
"go.wit.com/lib/gui/shell"
|
"go.wit.com/lib/gui/repolist"
|
||||||
"go.wit.com/lib/protobuf/gitpb"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type releaseStruct struct {
|
type releaseStruct struct {
|
||||||
|
@ -25,14 +26,14 @@ type releaseStruct struct {
|
||||||
releaseVersionB *gui.Node
|
releaseVersionB *gui.Node
|
||||||
reason *gadgets.BasicEntry
|
reason *gadgets.BasicEntry
|
||||||
|
|
||||||
// openrepo *gui.Node
|
openrepo *gui.Node
|
||||||
|
|
||||||
goGetB *gui.Node
|
goGetB *gui.Node
|
||||||
checkGoSumB *gui.Node
|
checkGoSumB *gui.Node
|
||||||
checkDirtyB *gui.Node
|
checkDirtyB *gui.Node
|
||||||
sendVersionB *gui.Node
|
sendVersionB *gui.Node
|
||||||
checkSafeB *gui.Node
|
checkSafeB *gui.Node
|
||||||
// whitelist map[string]*repolist.RepoRow
|
whitelist map[string]*repolist.RepoRow
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *autoType) Disable() {
|
func (w *autoType) Disable() {
|
||||||
|
@ -51,20 +52,14 @@ func createReleaseBox(box *gui.Node) {
|
||||||
|
|
||||||
me.release.releaseVersionB = me.release.grid.NewButton("release version", func() {
|
me.release.releaseVersionB = me.release.grid.NewButton("release version", func() {
|
||||||
buttonDisable()
|
buttonDisable()
|
||||||
fpath := me.current.FullPath
|
if doRelease() {
|
||||||
if err := doRelease(); err == nil {
|
|
||||||
buttonEnable()
|
buttonEnable()
|
||||||
log.Info("doRelease() worked", fpath)
|
log.Info("doRelease() worked")
|
||||||
} else {
|
} else {
|
||||||
log.Info("doRelease() failed", err, fpath)
|
log.Info("doRelease() failed")
|
||||||
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", func() {
|
me.release.grid.NewButton("Find Next Releasable", func() {
|
||||||
me.Disable()
|
me.Disable()
|
||||||
defer me.Enable()
|
defer me.Enable()
|
||||||
if findNext() {
|
if findNext() {
|
||||||
|
@ -72,18 +67,13 @@ func createReleaseBox(box *gui.Node) {
|
||||||
return
|
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.grid.NextRow()
|
||||||
|
|
||||||
me.release.repo = gadgets.NewOneLiner(me.release.grid, "repo")
|
me.release.repo = gadgets.NewOneLiner(me.release.grid, "repo")
|
||||||
|
me.release.openrepo = me.release.grid.NewButton("Configure", func() {
|
||||||
|
me.current.Status.Toggle()
|
||||||
|
})
|
||||||
|
me.release.openrepo.Disable()
|
||||||
me.release.grid.NextRow()
|
me.release.grid.NextRow()
|
||||||
me.release.status = gadgets.NewOneLiner(me.release.grid, "status")
|
me.release.status = gadgets.NewOneLiner(me.release.grid, "status")
|
||||||
me.release.grid.NextRow()
|
me.release.grid.NextRow()
|
||||||
|
@ -101,71 +91,178 @@ 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.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()
|
||||||
|
|
||||||
// me.userHomePwd.SetText(homeDir)
|
// me.userHomePwd.SetText(homeDir)
|
||||||
me.goSrcPwd.SetText(me.forge.Config.ReposDir)
|
me.goSrcPwd.SetText(me.forge.GetGoSrc())
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
|
grid.NewButton("whitelist", func() {
|
||||||
|
// tmp := me.current.GoState()
|
||||||
|
log.Info("trying to whitelist repo", me.current.GoPath())
|
||||||
|
me.current.Status.Whitelist = true
|
||||||
|
findNext()
|
||||||
|
})
|
||||||
|
|
||||||
grid.NextRow()
|
grid.NextRow()
|
||||||
|
|
||||||
group = me.release.box.NewGroup("Publish until done")
|
group = me.release.box.NewGroup("Process against all repos")
|
||||||
grid = group.NewGrid("buildOptions", 0, 0)
|
grid = group.NewGrid("buildOptions", 0, 0)
|
||||||
grid.NewButton("doRelease() all", func() {
|
grid.NewButton("doRelease() all", func() {
|
||||||
buttonDisable()
|
buttonDisable()
|
||||||
doReleaseAll()
|
// 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")
|
||||||
|
log.Info("os.Exit(0) here safely")
|
||||||
buttonEnable()
|
buttonEnable()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if first != second {
|
||||||
|
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() first =", first, "second =", second, "third =", third)
|
||||||
|
if !findOk {
|
||||||
|
log.Info("doRelease() immediately end something went wrong last time. findOk == false")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} 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?")
|
||||||
|
}
|
||||||
|
|
||||||
|
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()
|
||||||
|
|
||||||
|
grid.NewButton("git ls-files |grep go.mod", func() {
|
||||||
|
loop := me.repos.View.ReposSortByName()
|
||||||
|
for loop.Scan() {
|
||||||
|
repo := loop.Repo()
|
||||||
|
log.Info("repo:", repo.Name())
|
||||||
|
if repo.Status.ReadOnly() {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if repo.Status.Whitelist {
|
||||||
|
log.Warn("skipping whitelist", repo.GoPath())
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
good, files := repo.Status.GitLsFiles()
|
||||||
|
if !good {
|
||||||
|
log.Warn("Something went wrong", repo.GoPath())
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
for _, filename := range strings.Split(files, "\n") {
|
||||||
|
log.Info("\tfile", filename)
|
||||||
|
if filename == "go.mod" {
|
||||||
|
log.Info("Found go.mod. does version match release version?")
|
||||||
|
log.Info(repo.Status.GetLastTagVersion(), "vs", repo.Status.GetTargetVersion())
|
||||||
|
if repo.Status.GetLastTagVersion() != repo.Status.GetTargetVersion() {
|
||||||
|
log.Info(repo.Status.GetLastTagVersion(), "vs", repo.Status.GetTargetVersion())
|
||||||
|
log.Info("Found go.sum. version mismatch")
|
||||||
|
setCurrentRepo(repo, "VERY BROKEN", "rewind go.mod commit")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if filename == "go.sum" {
|
||||||
|
log.Info("Found go.sum. does version match release version?")
|
||||||
|
log.Info(repo.Status.GetLastTagVersion(), "vs", repo.Status.GetTargetVersion())
|
||||||
|
if repo.Status.GetLastTagVersion() != repo.Status.GetTargetVersion() {
|
||||||
|
log.Info(repo.Status.GetLastTagVersion(), "vs", repo.Status.GetTargetVersion())
|
||||||
|
log.Info("Found go.sum. version mismatch")
|
||||||
|
setCurrentRepo(repo, "VERY BROKEN", "rewind go.mod commit")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.Info("All repos seem okay")
|
||||||
})
|
})
|
||||||
grid.NextRow()
|
grid.NextRow()
|
||||||
}
|
}
|
||||||
|
|
||||||
func doReleaseAll() {
|
func doReleaseAll() (bool, time.Duration) {
|
||||||
count := 0
|
var worked bool = true
|
||||||
for {
|
findCounter = 0
|
||||||
log.Info("START doRelease() LOOP count =", count, "len me.done =", len(me.done))
|
duration := repolist.TimeFunction(func() {
|
||||||
if err := doRelease(); err != nil {
|
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
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if err := skipToNext(); err != nil {
|
if doRelease() {
|
||||||
break
|
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 os.Exit here")
|
||||||
}
|
}
|
||||||
count += 1
|
if me.release.status.String() == "ALL DONE?" {
|
||||||
if count > me.forge.Repos.Len() {
|
log.Info("maybe ALL DONE?. findCounter =", findCounter)
|
||||||
// never allow a loop longer than all the known repos
|
worked = true
|
||||||
// this probably doesn't matter, but often this code is wrong
|
// os.Exit(0)
|
||||||
// so this is a safety check. never remove this check.
|
}
|
||||||
|
log.Info("doRelease() failed. findCounter =", findCounter)
|
||||||
|
worked = false
|
||||||
break
|
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() {
|
func buttonDisable() {
|
||||||
|
|
|
@ -0,0 +1,73 @@
|
||||||
|
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
|
||||||
|
}
|
|
@ -1 +0,0 @@
|
||||||
* you can put toolkit .so binaries here
|
|
|
@ -0,0 +1,73 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
/*
|
||||||
|
func setTargetVersion() {
|
||||||
|
// go through and set the target versions for each repo
|
||||||
|
// todo: add sanity checking in repolist to verify these and/or autocompute them
|
||||||
|
// for now, just don't be stupid when you set your ENV vars
|
||||||
|
// widget I versioned early before I knew what the hell this would mean and can
|
||||||
|
// not be down versioned because that's not how GO versioning works. Once you
|
||||||
|
// set the version for a path, it's set in stone forever. (smart system!)
|
||||||
|
// we could rename go.wit.com/widget to go.wit.com/newwidget and restart the versioning
|
||||||
|
// system, but that's rediculous and this servers to always remind me to never make this mistake again
|
||||||
|
var count int
|
||||||
|
loop := me.repos.View.ReposSortByName()
|
||||||
|
for loop.Scan() {
|
||||||
|
repo := loop.Repo()
|
||||||
|
if repo == nil {
|
||||||
|
log.Info("initial scan repo = nil")
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if repo.Status == nil {
|
||||||
|
log.Info("repo.status == nil", repo.Name())
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if repo.GoPath() == "go.wit.com/widget" {
|
||||||
|
repo.Status.SetTargetVersion("v" + os.Getenv("GUIRELEASE_WIDGET"))
|
||||||
|
} else {
|
||||||
|
prefix := "v" + os.Getenv("GUIRELEASE_VERSION")
|
||||||
|
lasttag := repo.Status.LastTag()
|
||||||
|
if strings.HasPrefix(lasttag, prefix) {
|
||||||
|
repo.Status.SetTargetVersion(lasttag)
|
||||||
|
} else {
|
||||||
|
repo.Status.SetTargetVersion(prefix)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if strings.HasPrefix(repo.GoPath(), "go.wit.com/dev/") {
|
||||||
|
lasttag := repo.Status.GetLastTagVersion()
|
||||||
|
repo.Status.SetTargetVersion(lasttag)
|
||||||
|
}
|
||||||
|
// repo.NewScan()
|
||||||
|
count += 1
|
||||||
|
}
|
||||||
|
log.Info("target versions set for", count, "repos")
|
||||||
|
}
|
||||||
|
|
||||||
|
// trys to figure out if the version needs to be incremented
|
||||||
|
func incrementTargetVersion() bool {
|
||||||
|
var count int
|
||||||
|
loop := me.repos.View.ReposSortByName()
|
||||||
|
for loop.Scan() {
|
||||||
|
repo := loop.Repo()
|
||||||
|
if repo.ReadOnly() {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
lasttag := repo.Status.GetLastTagVersion()
|
||||||
|
master := repo.Status.GetMasterVersion()
|
||||||
|
|
||||||
|
if lasttag != master {
|
||||||
|
log.Info("increment target version", repo.GoPath(), lasttag, master)
|
||||||
|
count += 1
|
||||||
|
} else {
|
||||||
|
// check go dependancies for target version changes
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.Info("need to update target versions for", count, "repos")
|
||||||
|
if count == 0 {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
*/
|
55
structs.go
55
structs.go
|
@ -2,10 +2,9 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go.wit.com/dev/alexflint/arg"
|
|
||||||
"go.wit.com/gui"
|
"go.wit.com/gui"
|
||||||
"go.wit.com/lib/gadgets"
|
"go.wit.com/lib/gadgets"
|
||||||
"go.wit.com/lib/gui/prep"
|
"go.wit.com/lib/gui/repolist"
|
||||||
"go.wit.com/lib/protobuf/forgepb"
|
"go.wit.com/lib/protobuf/forgepb"
|
||||||
"go.wit.com/lib/protobuf/gitpb"
|
"go.wit.com/lib/protobuf/gitpb"
|
||||||
)
|
)
|
||||||
|
@ -13,17 +12,14 @@ import (
|
||||||
var me *autoType
|
var me *autoType
|
||||||
|
|
||||||
type autoType struct {
|
type autoType struct {
|
||||||
pp *arg.Parser // for parsing the command line args. Yay to alexf lint!
|
myGui *gui.Node
|
||||||
myGui *prep.GuiPrep // the gui handle itself
|
|
||||||
releaseReasonS string // = "gocui dropdown select"
|
releaseReasonS string // = "gocui dropdown select"
|
||||||
release releaseStruct // notsure
|
release releaseStruct
|
||||||
reposbox *gui.Node // notsure
|
reposbox *gui.Node
|
||||||
reposgrid *gui.Node // notsure
|
reposgrid *gui.Node
|
||||||
reposgroup *gui.Node // notsure
|
reposgroup *gui.Node
|
||||||
current *gitpb.Repo // tracks the next repo to publish
|
current *repolist.RepoRow
|
||||||
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
|
// this is the repo we are starting in
|
||||||
// make sure it never changes so go.mod and go.sum are always there
|
// make sure it never changes so go.mod and go.sum are always there
|
||||||
|
@ -31,10 +27,35 @@ type autoType struct {
|
||||||
startRepo *gitpb.Repo
|
startRepo *gitpb.Repo
|
||||||
|
|
||||||
// guireleaser window
|
// guireleaser window
|
||||||
mainWindow *gadgets.BasicWindow
|
mainWindow *gui.Node
|
||||||
mainBox *gui.Node
|
mainBox *gui.Node
|
||||||
|
|
||||||
forge *forgepb.Forge // your customized repo preferences and settings
|
// 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
|
||||||
|
|
||||||
// checkbox for --dry-run
|
// checkbox for --dry-run
|
||||||
autoDryRun *gui.Node
|
autoDryRun *gui.Node
|
||||||
|
@ -60,3 +81,9 @@ type autoType struct {
|
||||||
// show the time it took to do a scan
|
// show the time it took to do a scan
|
||||||
duration *gui.Node
|
duration *gui.Node
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
func (my *autoType) GoSrcPath() string {
|
||||||
|
return my.goSrcPwd.String()
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
Loading…
Reference in New Issue