guireleaser builds again
This commit is contained in:
parent
bbc78159fe
commit
08c7765cc7
4
Makefile
4
Makefile
|
@ -1,4 +1,4 @@
|
||||||
all:
|
all: build
|
||||||
./guireleaser
|
./guireleaser
|
||||||
|
|
||||||
stderr: build
|
stderr: build
|
||||||
|
@ -14,7 +14,7 @@ build:
|
||||||
echo "build it!"
|
echo "build it!"
|
||||||
-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/
|
||||||
go build -v -x
|
GO111MODULE=off go build -v -x
|
||||||
|
|
||||||
install:
|
install:
|
||||||
rm -f ~/go/src/go.wit.com/toolkits/*.so
|
rm -f ~/go/src/go.wit.com/toolkits/*.so
|
||||||
|
|
|
@ -29,22 +29,22 @@ func CheckReady() bool {
|
||||||
log.Info("find the next repo first")
|
log.Info("find the next repo first")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
goSumS := release.current.getGoSumStatus()
|
goSumS := release.current.Status.GetGoSumStatus()
|
||||||
dirtyS := release.current.dirtyLabel.String()
|
dirtyS := release.current.State()
|
||||||
lastS := release.current.status.GetLastTagVersion()
|
lastS := release.current.Status.GetLastTagVersion()
|
||||||
currentS := release.current.status.GetCurrentBranchVersion()
|
currentS := release.current.Status.GetCurrentBranchVersion()
|
||||||
|
|
||||||
var targetS string
|
var targetS string
|
||||||
targetS = release.version.String()
|
targetS = release.version.String()
|
||||||
|
|
||||||
log.Info("repo:", release.current.String(), goSumS, dirtyS, lastS, currentS, targetS)
|
log.Info("repo:", release.current.State(), goSumS, dirtyS, lastS, currentS, targetS)
|
||||||
|
|
||||||
if goSumS == "RELEASED" {
|
if goSumS == "RELEASED" {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if goSumS == "PRIMATIVE" {
|
if goSumS == "PRIMATIVE" {
|
||||||
if targetS == lastS {
|
if targetS == lastS {
|
||||||
release.current.setGoSumStatus("RELEASED")
|
release.current.Status.SetGoSumStatus("RELEASED")
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -53,45 +53,45 @@ func CheckReady() bool {
|
||||||
}
|
}
|
||||||
if goSumS == "READY" {
|
if goSumS == "READY" {
|
||||||
if targetS == lastS {
|
if targetS == lastS {
|
||||||
release.current.setGoSumStatus("RELEASED")
|
release.current.Status.SetGoSumStatus("RELEASED")
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if lastS == currentS {
|
if lastS == currentS {
|
||||||
release.current.setGoSumStatus("UNRELEASED")
|
release.current.Status.SetGoSumStatus("UNRELEASED")
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
release.current.setGoSumStatus("NOT READY")
|
release.current.Status.SetGoSumStatus("NOT READY")
|
||||||
if release.current.status.ReadOnly() {
|
if release.current.Status.ReadOnly() {
|
||||||
log.Info("\trepo is read only")
|
log.Info("\trepo is read only")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if targetS == lastS {
|
if targetS == lastS {
|
||||||
log.Info("\trepo is already done", lastS, "=", targetS)
|
log.Info("\trepo is already done", lastS, "=", targetS)
|
||||||
release.current.setGoSumStatus("READY")
|
release.current.Status.SetGoSumStatus("READY")
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if lastS == currentS {
|
if lastS == currentS {
|
||||||
log.Info("\trepo is already done", lastS, "=", targetS)
|
log.Info("\trepo is already done", lastS, "=", targetS)
|
||||||
release.current.setGoSumStatus("READY")
|
release.current.Status.SetGoSumStatus("READY")
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
if goSumS == "BAD" {
|
if goSumS == "BAD" {
|
||||||
log.Info("\trepo is ready", release.current.String(), "BAD == BAD")
|
log.Info("\trepo is ready", release.current.State(), "BAD == BAD")
|
||||||
} else {
|
} else {
|
||||||
log.Info("\trepo is ready maybe", release.current.String(), "BAD !=", goSumS)
|
log.Info("\trepo is ready maybe", release.current.State(), "BAD !=", goSumS)
|
||||||
}
|
}
|
||||||
|
|
||||||
if release.current.status.CheckDirty() {
|
if release.current.Status.CheckDirty() {
|
||||||
log.Info("\trepo is dirty")
|
log.Info("\trepo is dirty")
|
||||||
return false
|
return false
|
||||||
} else {
|
} else {
|
||||||
log.Info("\trepo is ready", release.current.String(), "not dirty")
|
log.Info("\trepo is ready", release.current.State(), "not dirty")
|
||||||
}
|
}
|
||||||
|
|
||||||
fullpath := filepath.Join(me.goSrcPwd.String(), release.current.String())
|
fullpath := filepath.Join(me.goSrcPwd.String(), release.current.State())
|
||||||
|
|
||||||
testf := filepath.Join(fullpath, "go.mod")
|
testf := filepath.Join(fullpath, "go.mod")
|
||||||
if Exists(testf) {
|
if Exists(testf) {
|
||||||
|
@ -113,14 +113,14 @@ func CheckReady() bool {
|
||||||
|
|
||||||
// final checks here
|
// final checks here
|
||||||
if dirtyS == "unchanged" {
|
if dirtyS == "unchanged" {
|
||||||
log.Info("\trepo is ready", release.current.String(), "unchanged")
|
log.Info("\trepo is ready", release.current.Name(), "unchanged")
|
||||||
} else {
|
} else {
|
||||||
log.Info("\trepo is not ready", dirtyS, "!= 'unchanged'")
|
log.Info("\trepo is not ready", dirtyS, "!= 'unchanged'")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
curName := release.current.status.GetCurrentBranchName()
|
curName := release.current.Status.GetCurrentBranchName()
|
||||||
mName := release.current.status.GetMasterBranchName()
|
mName := release.current.Status.GetMasterBranchName()
|
||||||
|
|
||||||
if curName == mName {
|
if curName == mName {
|
||||||
log.Info("\trepo is ready working from main branch", curName, "=", mName)
|
log.Info("\trepo is ready working from main branch", curName, "=", mName)
|
||||||
|
@ -129,7 +129,7 @@ func CheckReady() bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
release.current.setGoSumStatus("READY")
|
release.current.Status.SetGoSumStatus("READY")
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
52
doRelease.go
52
doRelease.go
|
@ -11,7 +11,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func doRelease() bool {
|
func doRelease() bool {
|
||||||
log.Info("doRelease() on", release.current.String())
|
log.Info("doRelease() on", release.current.Name())
|
||||||
// double check release version logic
|
// double check release version logic
|
||||||
if release.releaseVersionB.String() != "release version "+release.version.String() {
|
if release.releaseVersionB.String() != "release version "+release.version.String() {
|
||||||
log.Warn("something went wrong with the release.version:", release.version.String())
|
log.Warn("something went wrong with the release.version:", release.version.String())
|
||||||
|
@ -23,9 +23,9 @@ func doRelease() bool {
|
||||||
log.Warn("version does not start with v.", release.version.String())
|
log.Warn("version does not start with v.", release.version.String())
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
switch release.status.String() {
|
switch release.current.Status.GetGoSumStatus() {
|
||||||
case "PRIMATIVE":
|
case "PRIMATIVE":
|
||||||
log.Warn("can do PRIMATIVE", release.version.String())
|
log.Warn("can do PRIMATIVE", release.current.Name())
|
||||||
case "GOOD":
|
case "GOOD":
|
||||||
log.Warn("GOOD. lots of go.sum checks passed", release.version.String())
|
log.Warn("GOOD. lots of go.sum checks passed", release.version.String())
|
||||||
case "manually chosen":
|
case "manually chosen":
|
||||||
|
@ -41,21 +41,21 @@ func doRelease() bool {
|
||||||
log.Sleep(10)
|
log.Sleep(10)
|
||||||
*/
|
*/
|
||||||
default:
|
default:
|
||||||
log.Warn("what is this?", release.version.String(), release.status.String())
|
log.Warn("what is this?", release.version.String(), release.current.Name())
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if release.current.status.ReadOnly() {
|
if release.current.Status.ReadOnly() {
|
||||||
log.Info("sorry, it's read-only")
|
log.Info("sorry, it's read-only")
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if release.current.status.CheckDirty() {
|
if release.current.Status.CheckDirty() {
|
||||||
log.Info("sorry, it's still dirty")
|
log.Info("sorry, it's still dirty")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
curName := release.current.status.GetCurrentBranchName()
|
curName := release.current.Status.GetCurrentBranchName()
|
||||||
mName := release.current.status.GetMasterBranchName()
|
mName := release.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 false
|
return false
|
||||||
|
@ -65,7 +65,7 @@ func doRelease() bool {
|
||||||
|
|
||||||
var all [][]string
|
var all [][]string
|
||||||
all = append(all, []string{"git", "add", "-f", "go.mod"})
|
all = append(all, []string{"git", "add", "-f", "go.mod"})
|
||||||
if release.current.status.CheckPrimativeGoMod() {
|
if release.current.Status.CheckPrimativeGoMod() {
|
||||||
// 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"})
|
||||||
|
@ -75,7 +75,7 @@ func doRelease() bool {
|
||||||
all = append(all, []string{"git", "tag", "-m", me.releaseReasonS, release.version.String()})
|
all = append(all, []string{"git", "tag", "-m", me.releaseReasonS, release.version.String()})
|
||||||
all = append(all, []string{"git", "push", "origin", release.version.String()})
|
all = append(all, []string{"git", "push", "origin", release.version.String()})
|
||||||
|
|
||||||
if !release.current.status.DoAll(all) {
|
if !release.current.Status.DoAll(all) {
|
||||||
log.Info("failed to make new release", release.version.String())
|
log.Info("failed to make new release", release.version.String())
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -88,11 +88,11 @@ func doRelease() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Info("PUBLISH OK")
|
log.Info("PUBLISH OK")
|
||||||
release.current.setGoSumStatus("RELEASED")
|
release.current.Status.SetGoSumStatus("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 !release.current.status.RevertMasterToDevel() {
|
if !release.current.Status.RevertMasterToDevel() {
|
||||||
log.Info("Revert Failed")
|
log.Info("Revert Failed")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -104,27 +104,21 @@ func doRelease() bool {
|
||||||
retag = append(retag, []string{"git", "tag", "-m", me.releaseReasonS, release.version.String()})
|
retag = append(retag, []string{"git", "tag", "-m", me.releaseReasonS, release.version.String()})
|
||||||
retag = append(retag, []string{"git", "push", "origin", release.version.String()})
|
retag = append(retag, []string{"git", "push", "origin", release.version.String()})
|
||||||
|
|
||||||
if !release.current.status.DoAll(retag) {
|
if !release.current.Status.DoAll(retag) {
|
||||||
log.Info("retag failed")
|
log.Info("retag failed")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
log.Info("EVERYTHING OK. RERELEASED", release.current.String())
|
log.Info("EVERYTHING OK. RERELEASED", release.current.Name())
|
||||||
|
|
||||||
// update the package versions used for checking go.sum validity
|
|
||||||
release.current.status.UpdateNew()
|
|
||||||
cbname := release.current.status.GetCurrentBranchName()
|
|
||||||
cbversion := release.current.status.GetCurrentBranchVersion()
|
|
||||||
lasttag := release.current.status.GetLastTagVersion()
|
|
||||||
// update the values in the GUI
|
// update the values in the GUI
|
||||||
release.current.lastTag.SetLabel(lasttag)
|
release.current.Status.UpdateNew()
|
||||||
release.current.vLabel.SetLabel(cbname + " " + cbversion)
|
|
||||||
|
|
||||||
// attempt to find another repo to release
|
// attempt to find another repo to release
|
||||||
if !doReleaseFindNext() {
|
if !doReleaseFindNext() {
|
||||||
log.Info("doReleaseFindNext() could not find a new")
|
log.Info("doReleaseFindNext() could not find a new")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
log.Info("GOOD TO RUN ANOTHER DAY ON:", release.current.String())
|
log.Info("GOOD TO RUN ANOTHER DAY ON:", release.current.Name())
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,14 +131,14 @@ func doReleaseFindNext() bool {
|
||||||
log.Info("findNextDirty() could not find anything")
|
log.Info("findNextDirty() could not find anything")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
release.current.status.CheckSafeGoSumRemake()
|
release.current.Status.CheckSafeGoSumRemake()
|
||||||
if release.current.status.MakeRedomod() {
|
if release.current.Status.MakeRedomod() {
|
||||||
log.Info("Redo mod ok")
|
log.Info("Redo mod ok")
|
||||||
} else {
|
} else {
|
||||||
log.Info("go mod tidy not ok")
|
log.Info("go mod tidy not ok")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if ok, _ := release.current.status.CheckGoSum(); ok {
|
if ok, _ := release.current.Status.CheckGoSum(); ok {
|
||||||
log.Info("repo has go.sum requirements that are clean")
|
log.Info("repo has go.sum requirements that are clean")
|
||||||
// release.current.setGoSumStatus("CLEAN")
|
// release.current.setGoSumStatus("CLEAN")
|
||||||
release.status.SetValue("GOOD")
|
release.status.SetValue("GOOD")
|
||||||
|
@ -158,7 +152,7 @@ func doReleaseFindNext() bool {
|
||||||
// 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 := release.current.String()
|
gopath := release.current.GoPath()
|
||||||
cmd := []string{"go", "get", "-v", gopath + "@" + release.version.String()}
|
cmd := []string{"go", "get", "-v", gopath + "@" + release.version.String()}
|
||||||
log.Info("SHOULD RUN cmd HERE:", cmd)
|
log.Info("SHOULD RUN cmd HERE:", cmd)
|
||||||
|
|
||||||
|
@ -171,11 +165,11 @@ func doPublishVersion() bool {
|
||||||
gosum := filepath.Join(homeDir, "go/src/go.wit.com/apps/guireleaser/go.sum")
|
gosum := filepath.Join(homeDir, "go/src/go.wit.com/apps/guireleaser/go.sum")
|
||||||
if !shell.Exists(gosum) {
|
if !shell.Exists(gosum) {
|
||||||
log.Info("go.sum must exist here")
|
log.Info("go.sum must exist here")
|
||||||
release.guireleaser.status.MakeRedomod()
|
release.guireleaser.Status.MakeRedomod()
|
||||||
}
|
}
|
||||||
os.Unsetenv("GO111MODULE")
|
os.Unsetenv("GO111MODULE")
|
||||||
log.Info("TRYING TO SELF UPDATE HERE. cmd =", cmd)
|
log.Info("TRYING TO SELF UPDATE HERE. cmd =", cmd)
|
||||||
err, out := release.guireleaser.status.RunCmd(cmd)
|
err, out := release.guireleaser.Status.RunCmd(cmd)
|
||||||
if gopath == "go.wit.com/apps/guireleaser" {
|
if gopath == "go.wit.com/apps/guireleaser" {
|
||||||
// ignore errors on updating myself
|
// ignore errors on updating myself
|
||||||
log.Info("IGNORE SELF UPDATE ERROR. cmd =", cmd)
|
log.Info("IGNORE SELF UPDATE ERROR. cmd =", cmd)
|
||||||
|
@ -184,7 +178,7 @@ func doPublishVersion() bool {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
log.Info("SELF UPDATE OK. out =", out)
|
log.Info("SELF UPDATE OK. out =", out)
|
||||||
log.Info("SELF UPDATE WORKED")
|
log.Info("SELF UPDATE WORKED")
|
||||||
release.current.setGoSumStatus("RELEASED")
|
release.current.Status.SetGoSumStatus("RELEASED")
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
|
|
@ -11,21 +11,21 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func showHideRepos() {
|
func showHideRepos() {
|
||||||
for _, repo := range me.allrepos {
|
for _, repo := range me.repos.View.AllRepos() {
|
||||||
if me.autoHideReadOnly.Checked() {
|
if me.autoHideReadOnly.Checked() {
|
||||||
if repo.status.ReadOnly() {
|
if repo.Status.ReadOnly() {
|
||||||
repo.Hide()
|
repo.Hide()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if me.autoHidePerfect.Checked() {
|
if me.autoHidePerfect.Checked() {
|
||||||
if repo.dirtyLabel.String() == "PERFECT" {
|
if repo.State() == "PERFECT" {
|
||||||
repo.Hide()
|
repo.Hide()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if me.autoReleased.Checked() {
|
if me.autoReleased.Checked() {
|
||||||
if repo.getGoSumStatus() == "RELEASED" {
|
if repo.Status.GetGoSumStatus() == "RELEASED" {
|
||||||
repo.Hide()
|
repo.Hide()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -35,14 +35,14 @@ func showHideRepos() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func globalDisplayShow() {
|
func globalDisplayShow() {
|
||||||
for _, repo := range me.allrepos {
|
for _, repo := range me.repos.View.AllRepos() {
|
||||||
if me.autoHideReadOnly.Checked() {
|
if me.autoHideReadOnly.Checked() {
|
||||||
if repo.status.ReadOnly() {
|
if repo.Status.ReadOnly() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if me.autoHidePerfect.Checked() {
|
if me.autoHidePerfect.Checked() {
|
||||||
if repo.dirtyLabel.String() == "PERFECT" {
|
if repo.State() == "PERFECT" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,20 +56,19 @@ func globalDisplayOptions(box *gui.Node) {
|
||||||
group1 := vbox.NewGroup("Global Display Options")
|
group1 := vbox.NewGroup("Global Display Options")
|
||||||
|
|
||||||
group1.NewButton("Show Repository Window", func() {
|
group1.NewButton("Show Repository Window", func() {
|
||||||
if reposwin.Hidden() {
|
if me.repos.Hidden() {
|
||||||
|
me.repos.Show()
|
||||||
|
} else {
|
||||||
|
me.repos.Hide()
|
||||||
|
}
|
||||||
log.Info("showing reposwin")
|
log.Info("showing reposwin")
|
||||||
showHideRepos()
|
showHideRepos()
|
||||||
// have to run this twice for now
|
// have to run this twice for now
|
||||||
scanForReady()
|
// scanForReady()
|
||||||
scanForReady()
|
// scanForReady()
|
||||||
reposwin.Show()
|
// findNextDirty("")
|
||||||
findNextDirty("")
|
|
||||||
// double check the found next repo
|
// double check the found next repo
|
||||||
fullDoubleCheckFix()
|
// fullDoubleCheckFix()
|
||||||
} else {
|
|
||||||
log.Info("hiding reposwin")
|
|
||||||
reposwin.Hide()
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
me.autoHideReadOnly = group1.NewCheckbox("Hide read-only repos").SetChecked(true)
|
me.autoHideReadOnly = group1.NewCheckbox("Hide read-only repos").SetChecked(true)
|
||||||
|
@ -93,13 +92,13 @@ func globalDisplayOptions(box *gui.Node) {
|
||||||
me.autoReleased = group1.NewCheckbox("Hide RELEASED repos").SetChecked(false)
|
me.autoReleased = group1.NewCheckbox("Hide RELEASED repos").SetChecked(false)
|
||||||
me.autoReleased.Custom = func() {
|
me.autoReleased.Custom = func() {
|
||||||
if me.autoReleased.Checked() {
|
if me.autoReleased.Checked() {
|
||||||
for _, repo := range me.allrepos {
|
for _, repo := range me.repos.View.AllRepos() {
|
||||||
if repo.getGoSumStatus() == "RELEASED" {
|
if repo.Status.GetGoSumStatus() == "RELEASED" {
|
||||||
repo.Hide()
|
repo.Hide()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for _, repo := range me.allrepos {
|
for _, repo := range me.repos.View.AllRepos() {
|
||||||
repo.Show()
|
repo.Show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,21 +110,21 @@ func globalDisplayOptions(box *gui.Node) {
|
||||||
|
|
||||||
me.setBranchesToMasterB = group1.NewButton("set all branches to master", func() {
|
me.setBranchesToMasterB = group1.NewButton("set all branches to master", func() {
|
||||||
me.Disable()
|
me.Disable()
|
||||||
for _, repo := range me.allrepos {
|
for _, repo := range me.repos.View.AllRepos() {
|
||||||
if repo.status.ReadOnly() {
|
if repo.Status.ReadOnly() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if whitelist(repo.String()) {
|
if whitelist(repo.GoPath()) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if repo.status.CheckoutMaster() {
|
if repo.Status.CheckoutMaster() {
|
||||||
log.Warn("set master branch worked", repo.String())
|
log.Warn("set master branch worked", repo.Name())
|
||||||
repo.newScan()
|
repo.Status.UpdateNew()
|
||||||
} else {
|
} else {
|
||||||
repo.newScan()
|
repo.Status.UpdateNew()
|
||||||
log.Warn("set master branch failed", repo.String())
|
log.Warn("set master branch failed", repo.Name())
|
||||||
log.Warn("set master branch failed", repo.String())
|
log.Warn("set master branch failed", repo.Name())
|
||||||
log.Warn("set master branch failed", repo.String())
|
log.Warn("set master branch failed", repo.Name())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
me.Enable()
|
me.Enable()
|
||||||
|
@ -137,15 +136,15 @@ func globalDisplayOptions(box *gui.Node) {
|
||||||
os.Unsetenv("GO111MODULE")
|
os.Unsetenv("GO111MODULE")
|
||||||
longB.Disable()
|
longB.Disable()
|
||||||
me.Disable()
|
me.Disable()
|
||||||
for _, repo := range me.allrepos {
|
for _, repo := range me.repos.View.AllRepos() {
|
||||||
if whitelist(repo.String()) {
|
if whitelist(repo.GoPath()) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if repo.status.ReadOnly() {
|
if repo.Status.ReadOnly() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if repo.status.MakeRedomod() {
|
if repo.Status.MakeRedomod() {
|
||||||
log.Info("redo go.sum failed on", repo.String())
|
log.Info("redo go.sum failed on", repo.Name())
|
||||||
// me.Enable()
|
// me.Enable()
|
||||||
// longB.Enable()
|
// longB.Enable()
|
||||||
// longB.SetLabel("FAILED")
|
// longB.SetLabel("FAILED")
|
||||||
|
@ -160,54 +159,54 @@ func globalDisplayOptions(box *gui.Node) {
|
||||||
|
|
||||||
group1.NewButton("rm -f go.mod go.sum", func() {
|
group1.NewButton("rm -f go.mod go.sum", func() {
|
||||||
me.Disable()
|
me.Disable()
|
||||||
for _, repo := range me.allrepos {
|
for _, repo := range me.repos.View.AllRepos() {
|
||||||
if whitelist(repo.String()) {
|
if whitelist(repo.GoPath()) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if repo.status.ReadOnly() {
|
if repo.Status.ReadOnly() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
repo.status.RunCmd([]string{"rm", "-f", "go.mod", "go.sum"})
|
repo.Status.RunCmd([]string{"rm", "-f", "go.mod", "go.sum"})
|
||||||
}
|
}
|
||||||
me.Enable()
|
me.Enable()
|
||||||
})
|
})
|
||||||
|
|
||||||
group1.NewButton("git reset --hard", func() {
|
group1.NewButton("git reset --hard", func() {
|
||||||
me.Disable()
|
me.Disable()
|
||||||
for _, repo := range me.allrepos {
|
for _, repo := range me.repos.View.AllRepos() {
|
||||||
if whitelist(repo.String()) {
|
if whitelist(repo.GoPath()) {
|
||||||
log.Warn("skipping whitelist", repo.String())
|
log.Warn("skipping whitelist", repo.Name())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
log.Warn("running git reset --hard", repo.String())
|
log.Warn("running git reset --hard", repo.Name())
|
||||||
repo.status.RunCmd([]string{"git", "reset", "--hard"})
|
repo.Status.RunCmd([]string{"git", "reset", "--hard"})
|
||||||
}
|
}
|
||||||
me.Enable()
|
me.Enable()
|
||||||
})
|
})
|
||||||
|
|
||||||
group1.NewButton("git ls-files |grep go.mod", func() {
|
group1.NewButton("git ls-files |grep go.mod", func() {
|
||||||
// var all []string
|
// var all []string
|
||||||
for _, repo := range me.allrepos {
|
for _, repo := range me.repos.View.AllRepos() {
|
||||||
log.Info("repo:", repo.String())
|
log.Info("repo:", repo.Name())
|
||||||
if repo.status.ReadOnly() {
|
if repo.Status.ReadOnly() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if whitelist(repo.String()) {
|
if whitelist(repo.GoPath()) {
|
||||||
log.Warn("skipping whitelist", repo.String())
|
log.Warn("skipping whitelist", repo.GoPath())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
good, files := repo.status.GitLsFiles()
|
good, files := repo.Status.GitLsFiles()
|
||||||
if !good {
|
if !good {
|
||||||
log.Warn("Something went wrong", repo.String())
|
log.Warn("Something went wrong", repo.GoPath())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
for _, filename := range strings.Split(files, "\n") {
|
for _, filename := range strings.Split(files, "\n") {
|
||||||
log.Info("\tfile", filename)
|
log.Info("\tfile", filename)
|
||||||
if filename == "go.mod" {
|
if filename == "go.mod" {
|
||||||
log.Info("Found go.mod. does version match release version?")
|
log.Info("Found go.mod. does version match release version?")
|
||||||
log.Info(repo.lastTag.String(), "vs", repo.targetVersion.String())
|
log.Info(repo.Status.GetLastTagVersion(), "vs", repo.Status.GetTargetVersion())
|
||||||
if repo.lastTag.String() != repo.targetVersion.String() {
|
if repo.Status.GetLastTagVersion() != repo.Status.GetTargetVersion() {
|
||||||
log.Info(repo.lastTag.String(), "vs", repo.targetVersion.String())
|
log.Info(repo.Status.GetLastTagVersion(), "vs", repo.Status.GetTargetVersion())
|
||||||
log.Info("Found go.sum. version mismatch")
|
log.Info("Found go.sum. version mismatch")
|
||||||
setCurrentRepo(repo, "VERY BROKEN", "rewind go.mod commit")
|
setCurrentRepo(repo, "VERY BROKEN", "rewind go.mod commit")
|
||||||
return
|
return
|
||||||
|
@ -215,9 +214,9 @@ func globalDisplayOptions(box *gui.Node) {
|
||||||
}
|
}
|
||||||
if filename == "go.sum" {
|
if filename == "go.sum" {
|
||||||
log.Info("Found go.sum. does version match release version?")
|
log.Info("Found go.sum. does version match release version?")
|
||||||
log.Info(repo.lastTag.String(), "vs", repo.targetVersion.String())
|
log.Info(repo.Status.GetLastTagVersion(), "vs", repo.Status.GetTargetVersion())
|
||||||
if repo.lastTag.String() != repo.targetVersion.String() {
|
if repo.Status.GetLastTagVersion() != repo.Status.GetTargetVersion() {
|
||||||
log.Info(repo.lastTag.String(), "vs", repo.targetVersion.String())
|
log.Info(repo.Status.GetLastTagVersion(), "vs", repo.Status.GetTargetVersion())
|
||||||
log.Info("Found go.sum. version mismatch")
|
log.Info("Found go.sum. version mismatch")
|
||||||
setCurrentRepo(repo, "VERY BROKEN", "rewind go.mod commit")
|
setCurrentRepo(repo, "VERY BROKEN", "rewind go.mod commit")
|
||||||
return
|
return
|
||||||
|
@ -239,9 +238,9 @@ func globalDisplayOptions(box *gui.Node) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func hidePerfect() {
|
func hidePerfect() {
|
||||||
for _, repo := range me.allrepos {
|
for _, repo := range me.repos.View.AllRepos() {
|
||||||
if repo.dirtyLabel.String() == "PERFECT" {
|
if repo.State() == "PERFECT" {
|
||||||
if repo.hidden {
|
if repo.Hidden() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
repo.Hide()
|
repo.Hide()
|
||||||
|
|
|
@ -0,0 +1,66 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
// this initializes the repos
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
|
"os/user"
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"go.wit.com/lib/gui/repolist"
|
||||||
|
"go.wit.com/lib/gui/repostatus"
|
||||||
|
"go.wit.com/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (r *repoWindow) initRepoList() {
|
||||||
|
usr, _ := user.Current()
|
||||||
|
|
||||||
|
repos := parsecfg("~/.config/guireleaser")
|
||||||
|
for _, line := range repos {
|
||||||
|
log.Verbose("repo =", line)
|
||||||
|
path, mbranch, dbranch, ubranch := splitLine(line)
|
||||||
|
if mbranch == "" {
|
||||||
|
mbranch = "master"
|
||||||
|
}
|
||||||
|
if dbranch == "" {
|
||||||
|
dbranch = "devel"
|
||||||
|
}
|
||||||
|
if ubranch == "" {
|
||||||
|
ubranch = usr.Username
|
||||||
|
}
|
||||||
|
r.View.AddRepo(path, mbranch, dbranch, ubranch)
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Info("scanning everything in ~/go/src")
|
||||||
|
for i, path := range repostatus.ListGitDirectories() {
|
||||||
|
// log.Info("addRepo()", i, path)
|
||||||
|
path = strings.TrimPrefix(path, me.goSrcPwd.String())
|
||||||
|
path = strings.Trim(path, "/")
|
||||||
|
log.Info("addRepo()", i, path)
|
||||||
|
r.View.AddRepo(path, "master", "devel", usr.Username)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func parsecfg(f string) []string {
|
||||||
|
homeDir, _ := os.UserHomeDir()
|
||||||
|
cfgfile := filepath.Join(homeDir, f)
|
||||||
|
content, _ := ioutil.ReadFile(cfgfile)
|
||||||
|
out := string(content)
|
||||||
|
out = strings.TrimSpace(out)
|
||||||
|
lines := strings.Split(out, "\n")
|
||||||
|
return lines
|
||||||
|
}
|
||||||
|
|
||||||
|
// returns path, master branch name, devel branch name, user branch name
|
||||||
|
func splitLine(line string) (string, string, string, string) {
|
||||||
|
var path, master, devel, user string
|
||||||
|
parts := strings.Split(line, " ")
|
||||||
|
path, parts = repolist.RemoveFirstElement(parts)
|
||||||
|
master, parts = repolist.RemoveFirstElement(parts)
|
||||||
|
devel, parts = repolist.RemoveFirstElement(parts)
|
||||||
|
user, parts = repolist.RemoveFirstElement(parts)
|
||||||
|
// path, master, devel, user := strings.Split(line, " ")
|
||||||
|
return path, master, devel, user
|
||||||
|
}
|
|
@ -4,54 +4,55 @@ package main
|
||||||
import (
|
import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
|
"go.wit.com/lib/gui/repolist"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (r *repo) lookToUnwind() bool {
|
func lookToUnwind(r *repolist.Repo) bool {
|
||||||
goSumS := r.getGoSumStatus()
|
goSumS := r.Status.GetGoSumStatus()
|
||||||
dirtyS := r.dirtyLabel.String()
|
dirtyS := r.State()
|
||||||
currentS := r.status.GetCurrentBranchVersion()
|
currentS := r.Status.GetCurrentBranchVersion()
|
||||||
log.Info("repo:", r.String(), goSumS, dirtyS, r.lastTag.String(), currentS)
|
log.Info("repo:", r.Name(), goSumS, dirtyS, r.State(), currentS)
|
||||||
|
|
||||||
curName := r.status.GetCurrentBranchName()
|
curName := r.Status.GetCurrentBranchName()
|
||||||
mName := r.status.GetMasterBranchName()
|
mName := r.Status.GetMasterBranchName()
|
||||||
|
|
||||||
if curName == mName {
|
if curName == mName {
|
||||||
log.Info("\trepo is ready working from main branch", curName, "=", mName)
|
log.Info("\trepo is ready working from main branch", curName, "=", mName)
|
||||||
} else {
|
} else {
|
||||||
log.Info("\trepo is not ready main branch", curName, "!=", mName)
|
log.Info("\trepo is not ready main branch", curName, "!=", mName)
|
||||||
r.setGoSumStatus("CAN NOT UNWIND")
|
r.Status.SetGoSumStatus("CAN NOT UNWIND")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if r.lastTag.String() != currentS {
|
if r.LastTag() != currentS {
|
||||||
log.Info("\trepo version mismatch last vs current", r.lastTag.String(), "!=", currentS)
|
log.Info("\trepo version mismatch last vs current", r.LastTag(), "!=", currentS)
|
||||||
r.setGoSumStatus("CAN NOT UNWIND")
|
r.Status.SetGoSumStatus("CAN NOT UNWIND")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if release.version.String() != r.lastTag.String() {
|
if release.version.String() != r.LastTag() {
|
||||||
log.Info("\trepo version mismatch last vs official", r.lastTag.String(), "!=", release.version.String())
|
log.Info("\trepo version mismatch last vs official", r.LastTag(), "!=", release.version.String())
|
||||||
r.setGoSumStatus("CAN NOT UNWIND")
|
r.Status.SetGoSumStatus("CAN NOT UNWIND")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
fullpath := filepath.Join(me.goSrcPwd.String(), r.String())
|
fullpath := filepath.Join(me.goSrcPwd.String(), r.GoPath())
|
||||||
testf := filepath.Join(fullpath, "go.mod")
|
testf := filepath.Join(fullpath, "go.mod")
|
||||||
if Exists(testf) {
|
if Exists(testf) {
|
||||||
log.Info("\trepo is ready. go.mod exists")
|
log.Info("\trepo is ready. go.mod exists")
|
||||||
r.setGoSumStatus("UNWIND")
|
r.Status.SetGoSumStatus("UNWIND")
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
fullpath = filepath.Join(me.goSrcPwd.String(), r.String())
|
fullpath = filepath.Join(me.GoSrcPath(), r.GoPath())
|
||||||
testf = filepath.Join(fullpath, "go.sum")
|
testf = filepath.Join(fullpath, "go.sum")
|
||||||
if Exists(testf) {
|
if Exists(testf) {
|
||||||
log.Info("\trepo is ready. go.sum exists")
|
log.Info("\trepo is ready. go.sum exists")
|
||||||
r.setGoSumStatus("UNWIND")
|
r.Status.SetGoSumStatus("UNWIND")
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
r.setGoSumStatus("NO UNWIND?")
|
r.Status.SetGoSumStatus("NO UNWIND?")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
125
main.go
125
main.go
|
@ -2,11 +2,9 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"embed"
|
"embed"
|
||||||
"fmt"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
|
||||||
|
|
||||||
"go.wit.com/gui"
|
"go.wit.com/gui"
|
||||||
"go.wit.com/lib/gui/shell"
|
"go.wit.com/lib/gui/shell"
|
||||||
|
@ -23,7 +21,6 @@ var resToolkit embed.FS
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
me = new(autoType)
|
me = new(autoType)
|
||||||
me.allrepos = make(map[string]*repo)
|
|
||||||
|
|
||||||
// TODO: autocompute these in the gui
|
// TODO: autocompute these in the gui
|
||||||
releaseReasonS = os.Getenv("GUIRELEASE_REASON")
|
releaseReasonS = os.Getenv("GUIRELEASE_REASON")
|
||||||
|
@ -39,11 +36,15 @@ func main() {
|
||||||
me.myGui.InitEmbed(resToolkit)
|
me.myGui.InitEmbed(resToolkit)
|
||||||
me.myGui.Default()
|
me.myGui.Default()
|
||||||
|
|
||||||
|
// our main window
|
||||||
me.mainWindow = me.myGui.NewWindow("GUI release manager")
|
me.mainWindow = me.myGui.NewWindow("GUI release manager")
|
||||||
me.mainBox = me.mainWindow.NewBox("bw hbox", true)
|
me.mainBox = me.mainWindow.NewBox("bw hbox", true)
|
||||||
|
|
||||||
|
// the left side of the window options
|
||||||
globalDisplayOptions(me.mainBox)
|
globalDisplayOptions(me.mainBox)
|
||||||
|
|
||||||
|
// sanity check of things that might be around that mess
|
||||||
|
// up things later
|
||||||
// if you have a go.work file, you must delete it
|
// if you have a go.work file, you must delete it
|
||||||
// TODO: check for go.work files anywhere
|
// TODO: check for go.work files anywhere
|
||||||
homeDir, _ := os.UserHomeDir()
|
homeDir, _ := os.UserHomeDir()
|
||||||
|
@ -53,95 +54,101 @@ func main() {
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// sanity check of things that might be around that mess
|
||||||
|
// up things later
|
||||||
|
// check to make sure we have a go.sum here
|
||||||
gosum := filepath.Join(homeDir, "go/src/go.wit.com/apps/guireleaser/go.sum")
|
gosum := filepath.Join(homeDir, "go/src/go.wit.com/apps/guireleaser/go.sum")
|
||||||
if !shell.Exists(gosum) {
|
if !shell.Exists(gosum) {
|
||||||
log.Info("go.sum must exist here")
|
log.Info("go.sum must exist here")
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
repoworld()
|
// save the ENV var here
|
||||||
|
|
||||||
me.releaseReasonS = releaseReasonS
|
me.releaseReasonS = releaseReasonS
|
||||||
|
|
||||||
for i, repo := range me.allrepos {
|
me.repos = makeRepoView()
|
||||||
|
|
||||||
|
// 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
|
||||||
|
for i, repo := range me.repos.View.AllRepos() {
|
||||||
if repo == nil {
|
if repo == nil {
|
||||||
log.Info("initial scan i = nil", i)
|
log.Info("initial scan i = nil", i)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Info("initial scan repo", repo.String())
|
log.Info("initial scan repo", repo.Name())
|
||||||
if repo.status == nil {
|
if repo.Status == nil {
|
||||||
log.Info("repo.status == nil", repo.String())
|
log.Info("repo.status == nil", repo.Name())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
repo.status.UpdateNew()
|
if repo.GoPath() == "go.wit.com/widget" {
|
||||||
repo.newScan()
|
repo.Status.SetTargetVersion("v" + widgetVersion)
|
||||||
|
|
||||||
if repo.String() == "go.wit.com/widget" {
|
|
||||||
repo.targetVersion.SetText("v" + widgetVersion)
|
|
||||||
} else {
|
} else {
|
||||||
repo.targetVersion.SetText("v" + releaseVersion)
|
repo.Status.SetTargetVersion("v" + releaseVersion)
|
||||||
}
|
}
|
||||||
if strings.HasPrefix(repo.String(), "go.wit.com/dev/") {
|
if strings.HasPrefix(repo.GoPath(), "go.wit.com/dev/") {
|
||||||
lasttag := repo.status.GetLastTagVersion()
|
lasttag := repo.Status.GetLastTagVersion()
|
||||||
repo.targetVersion.SetText(lasttag)
|
repo.Status.SetTargetVersion(lasttag)
|
||||||
}
|
}
|
||||||
// if repo.String() == "go.wit.com/apps/guireleaser" {
|
|
||||||
}
|
}
|
||||||
log.Info("Creating the Release Window")
|
log.Info("Creating the Release Window")
|
||||||
|
|
||||||
|
// create the right side of the main window
|
||||||
createReleaseBox(me.mainBox)
|
createReleaseBox(me.mainBox)
|
||||||
// createUnreleaseBox(me.mainBox)
|
|
||||||
|
|
||||||
for _, repo := range me.allrepos {
|
|
||||||
if repo.status.ReadOnly() {
|
// start the initail scan and make sure each repo is set
|
||||||
|
// to the master branch
|
||||||
|
for _, repo := range me.repos.View.AllRepos() {
|
||||||
|
if repo.ReadOnly() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if whitelist(repo.String()) {
|
if whitelist(repo.GoPath()) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if repo.status.CheckoutMaster() {
|
if repo.Status.CheckoutMaster() {
|
||||||
log.Warn("set master branch worked", repo.String())
|
log.Warn("git checkout master branch worked", repo.Name())
|
||||||
repo.newScan()
|
repo.Status.UpdateNew()
|
||||||
} else {
|
} else {
|
||||||
repo.newScan()
|
repo.Status.UpdateNew()
|
||||||
log.Warn("set master branch failed", repo.String())
|
log.Warn("git checkout master branch failed", repo.Name())
|
||||||
log.Warn("set master branch failed", repo.String())
|
|
||||||
log.Warn("set master branch failed", repo.String())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
showHideRepos()
|
// 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.
|
||||||
release.openrepo.Disable()
|
release.openrepo.Disable()
|
||||||
|
|
||||||
// scan repos every 30 seconds
|
// I don't know what this is autotypist thing?
|
||||||
// check every second for the checkbox changing
|
// globalResetOptions(me.mainbox)
|
||||||
var i int = 60
|
|
||||||
myTicker(1*time.Second, "newScan()", func() {
|
// hopefully this is the list of all the golang packages and only the GUI golang packages
|
||||||
i += 1
|
me.repos = makeRepoView()
|
||||||
if !me.scanEveryMinute.Checked() {
|
|
||||||
if i < 60 {
|
// parse config file and scan for .git repos
|
||||||
i = 60
|
me.repos.initRepoList()
|
||||||
}
|
|
||||||
// print every 13 seconds
|
// reads in the State of all the repos
|
||||||
if i%13 == 0 {
|
// TODO: should not really be necessary directly after init()
|
||||||
log.Info("Not auto scanning", i)
|
me.repos.View.ScanRepositories()
|
||||||
}
|
|
||||||
return
|
me.Enable()
|
||||||
}
|
|
||||||
if i < 60 {
|
// intermittently scans the status indefinitly
|
||||||
return
|
me.repos.View.Watchdog(func() {
|
||||||
}
|
log.Info("In main()")
|
||||||
i = 0
|
// processing is done. update the repo summary box
|
||||||
duration := timeFunction(func() {
|
// me.summary.Update()
|
||||||
scanGoSum()
|
|
||||||
for _, repo := range me.allrepos {
|
|
||||||
repo.newScan()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
s := fmt.Sprint(duration)
|
|
||||||
me.autoWorkingPwd.SetText(s)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
192
releaseBox.go
192
releaseBox.go
|
@ -10,12 +10,13 @@ import (
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
|
|
||||||
"go.wit.com/lib/gadgets"
|
"go.wit.com/lib/gadgets"
|
||||||
|
"go.wit.com/lib/gui/repolist"
|
||||||
)
|
)
|
||||||
|
|
||||||
var release releaseStruct
|
var release releaseStruct
|
||||||
|
|
||||||
type releaseStruct struct {
|
type releaseStruct struct {
|
||||||
current *repo
|
current *repolist.Repo
|
||||||
|
|
||||||
box *gui.Node
|
box *gui.Node
|
||||||
group *gui.Node
|
group *gui.Node
|
||||||
|
@ -40,11 +41,11 @@ type releaseStruct struct {
|
||||||
makeRedomodB *gui.Node
|
makeRedomodB *gui.Node
|
||||||
sendVersionB *gui.Node
|
sendVersionB *gui.Node
|
||||||
checkSafeB *gui.Node
|
checkSafeB *gui.Node
|
||||||
whitelist map[string]*repo
|
whitelist map[string]*repolist.Repo
|
||||||
|
|
||||||
// store myself here. use myself to
|
// store myself here. use myself to
|
||||||
// do garbage go get tests and other potential junk
|
// do garbage go get tests and other potential junk
|
||||||
guireleaser *repo
|
guireleaser *repolist.Repo
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *autoType) Disable() {
|
func (w *autoType) Disable() {
|
||||||
|
@ -75,6 +76,7 @@ func createReleaseBox(box *gui.Node) {
|
||||||
me.Enable()
|
me.Enable()
|
||||||
})
|
})
|
||||||
release.grid.NewButton("findNextDirty()", func() {
|
release.grid.NewButton("findNextDirty()", func() {
|
||||||
|
/*
|
||||||
me.Disable()
|
me.Disable()
|
||||||
defer me.Enable()
|
defer me.Enable()
|
||||||
if findNextDirty("PRIMATIVE") {
|
if findNextDirty("PRIMATIVE") {
|
||||||
|
@ -85,6 +87,7 @@ func createReleaseBox(box *gui.Node) {
|
||||||
log.Info("findNextDirty() found a repo")
|
log.Info("findNextDirty() found a repo")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
})
|
})
|
||||||
|
|
||||||
release.releaseVersionB = release.grid.NewButton("release version", func() {
|
release.releaseVersionB = release.grid.NewButton("release version", func() {
|
||||||
|
@ -98,7 +101,7 @@ func createReleaseBox(box *gui.Node) {
|
||||||
})
|
})
|
||||||
|
|
||||||
release.openrepo = release.grid.NewButton("open repo", func() {
|
release.openrepo = release.grid.NewButton("open repo", func() {
|
||||||
release.current.status.Toggle()
|
release.current.Status.Toggle()
|
||||||
})
|
})
|
||||||
release.openrepo.Disable()
|
release.openrepo.Disable()
|
||||||
|
|
||||||
|
@ -134,22 +137,22 @@ func createReleaseBox(box *gui.Node) {
|
||||||
release.grid.NewButton("Check Ready", func() {
|
release.grid.NewButton("Check Ready", func() {
|
||||||
buttonDisable()
|
buttonDisable()
|
||||||
defer buttonEnable()
|
defer buttonEnable()
|
||||||
goSumS := release.current.getGoSumStatus()
|
goSumS := release.current.GoState()
|
||||||
dirtyS := release.current.dirtyLabel.String()
|
dirtyS := release.current.State()
|
||||||
lastS := release.current.status.GetLastTagVersion()
|
lastS := release.current.LastTag()
|
||||||
if CheckReady() {
|
if CheckReady() {
|
||||||
log.Info("repo is ready", release.current.String(), goSumS, dirtyS, lastS)
|
log.Info("repo is ready", release.current.Name(), goSumS, dirtyS, lastS)
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
log.Info("\trepo is not ready", release.current.String(), goSumS, dirtyS, lastS)
|
log.Info("\trepo is not ready", release.current.Name(), goSumS, dirtyS, lastS)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
release.grid.NewButton("set ignore", func() {
|
release.grid.NewButton("set ignore", func() {
|
||||||
tmp := release.current.getGoSumStatus()
|
tmp := release.current.GoState()
|
||||||
log.Info("trying to set repo IGNORE is now =", tmp)
|
log.Info("trying to set repo IGNORE is now =", tmp)
|
||||||
release.current.setGoSumStatus("IGNORE")
|
release.current.SetGoState("IGNORE")
|
||||||
release.whitelist[release.current.String()] = release.current
|
release.whitelist[release.current.GoPath()] = release.current
|
||||||
})
|
})
|
||||||
|
|
||||||
release.checkSafeB = release.grid.NewButton("fullDoubleCheckFix()", func() {
|
release.checkSafeB = release.grid.NewButton("fullDoubleCheckFix()", func() {
|
||||||
|
@ -165,18 +168,18 @@ func createReleaseBox(box *gui.Node) {
|
||||||
|
|
||||||
release.checkGoSumB = release.grid.NewButton("CheckGoSum()", func() {
|
release.checkGoSumB = release.grid.NewButton("CheckGoSum()", func() {
|
||||||
buttonDisable()
|
buttonDisable()
|
||||||
if ok, _ := release.current.status.CheckGoSum(); ok {
|
if ok, _ := release.current.Status.CheckGoSum(); ok {
|
||||||
log.Info("repo has go.sum requirements that are clean")
|
log.Info("repo has go.sum requirements that are clean")
|
||||||
// release.current.setGoSumStatus("CLEAN")
|
// release.current.setGoSumStatus("CLEAN")
|
||||||
release.status.SetValue("GOOD")
|
release.status.SetText("GOOD")
|
||||||
release.notes.SetValue("CheckGoSum() does not seem to lie")
|
release.notes.SetText("CheckGoSum() does not seem to lie")
|
||||||
}
|
}
|
||||||
buttonEnable()
|
buttonEnable()
|
||||||
})
|
})
|
||||||
|
|
||||||
release.makeRedomodB = release.grid.NewButton("make redomod", func() {
|
release.makeRedomodB = release.grid.NewButton("make redomod", func() {
|
||||||
buttonDisable()
|
buttonDisable()
|
||||||
if release.current.status.MakeRedomod() {
|
if release.current.Status.MakeRedomod() {
|
||||||
} else {
|
} else {
|
||||||
log.Info("This is bad. stop here")
|
log.Info("This is bad. stop here")
|
||||||
}
|
}
|
||||||
|
@ -198,8 +201,8 @@ func createReleaseBox(box *gui.Node) {
|
||||||
buttonDisable()
|
buttonDisable()
|
||||||
// rather than loop forever, at least limit this to the number of repos
|
// rather than loop forever, at least limit this to the number of repos
|
||||||
// incase something, somewhere, goes wrong
|
// incase something, somewhere, goes wrong
|
||||||
duration := timeFunction(func() {
|
duration := repolist.TimeFunction(func() {
|
||||||
for n := 0; n <= len(me.allrepos); n++ {
|
for n := 0; n <= len(me.repos.View.AllRepos()); n++ {
|
||||||
if doRelease() {
|
if doRelease() {
|
||||||
log.Info("doRelease() worked")
|
log.Info("doRelease() worked")
|
||||||
} else {
|
} else {
|
||||||
|
@ -222,18 +225,18 @@ func createReleaseBox(box *gui.Node) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func fullDoubleCheckFix() bool {
|
func fullDoubleCheckFix() bool {
|
||||||
release.current.status.CheckSafeGoSumRemake()
|
release.current.Status.CheckSafeGoSumRemake()
|
||||||
if !release.current.status.MakeRedomod() {
|
if !release.current.Status.MakeRedomod() {
|
||||||
log.Info("go mod failed")
|
log.Info("go mod failed")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if ok, _ := release.current.status.CheckGoSum(); ok {
|
if ok, _ := release.current.Status.CheckGoSum(); ok {
|
||||||
log.Info("go.sum is clean")
|
log.Info("go.sum is clean")
|
||||||
} else {
|
} else {
|
||||||
log.Info("repo go.sum FAILED")
|
log.Info("repo go.sum FAILED")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if ok, _ := release.current.status.CheckGoSum(); ok {
|
if ok, _ := release.current.Status.CheckGoSum(); ok {
|
||||||
log.Info("repo has go.sum requirements that are clean")
|
log.Info("repo has go.sum requirements that are clean")
|
||||||
// release.current.setGoSumStatus("CLEAN")
|
// release.current.setGoSumStatus("CLEAN")
|
||||||
release.status.SetValue("GOOD")
|
release.status.SetValue("GOOD")
|
||||||
|
@ -244,16 +247,19 @@ func fullDoubleCheckFix() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func goodCheckGoSum() bool {
|
func goodCheckGoSum() bool {
|
||||||
tmp := release.current.String()
|
tmp := release.current.Name()
|
||||||
log.Info("goodCheckGoSum() START on repo:", tmp, "STATUS =", release.current.getGoSumStatus())
|
log.Info("goodCheckGoSum() START on repo:", tmp, "STATUS =", release.current.GoState())
|
||||||
|
|
||||||
var maybe bool = true
|
var maybe bool = true
|
||||||
goConfig := release.current.status.GetGoDeps()
|
goConfig := release.current.Status.GetGoDeps()
|
||||||
for depname, version := range goConfig {
|
for depname, version := range goConfig {
|
||||||
log.Info("Checking repo deps:", depname, version)
|
log.Info("Checking repo deps:", depname, version)
|
||||||
repo, ok := me.allrepos[depname]
|
repo := me.repos.View.FindRepo(depname)
|
||||||
if ok {
|
if repo != nil {
|
||||||
goSumS := repo.getGoSumStatus()
|
log.Info(" repo deps: IGNORE", depname, version)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
goSumS := repo.GoState()
|
||||||
// ignore dependencies on whitelisted repos
|
// ignore dependencies on whitelisted repos
|
||||||
// TODO: warn the user about the whitelist
|
// TODO: warn the user about the whitelist
|
||||||
if goSumS == "WHITELIST" {
|
if goSumS == "WHITELIST" {
|
||||||
|
@ -262,25 +268,22 @@ func goodCheckGoSum() bool {
|
||||||
// check if the dependent repo is ReadOnly
|
// check if the dependent repo is ReadOnly
|
||||||
// if so, there isn't anything we can do about
|
// if so, there isn't anything we can do about
|
||||||
// version mis-matches
|
// version mis-matches
|
||||||
if repo.status.ReadOnly() {
|
if repo.ReadOnly() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
lastS := repo.status.GetLastTagVersion()
|
lastS := repo.LastTag()
|
||||||
targetS := repo.targetVersion.String()
|
targetS := repo.Status.GetTargetVersion()
|
||||||
log.Info(" repo deps:", depname, version, "vs", goSumS, lastS, targetS)
|
log.Info(" repo deps:", depname, version, "vs", goSumS, lastS, targetS)
|
||||||
if lastS != targetS {
|
if lastS != targetS {
|
||||||
log.Info("repo deps: FALSE lastS != targetS", lastS, targetS)
|
log.Info("repo deps: FALSE lastS != targetS", lastS, targetS)
|
||||||
log.Info("repo deps: FALSE status.ReadOnly()", release.current.status.ReadOnly())
|
log.Info("repo deps: FALSE status.ReadOnly()", release.current.ReadOnly())
|
||||||
log.Info("repo deps: FALSE path", release.current.String())
|
log.Info("repo deps: FALSE path", release.current.GoPath())
|
||||||
maybe = false
|
maybe = false
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
log.Info(" repo deps: IGNORE", depname, version)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if maybe {
|
if maybe {
|
||||||
log.Info("SUCCEEDED.", release.current.String())
|
log.Info("SUCCEEDED.", release.current.Name())
|
||||||
log.Info("SUCCEEDED. goSumStatus.String() =", release.current.goSumStatus.String())
|
log.Info("SUCCEEDED. goSumStatus.String() =", release.current.GoState())
|
||||||
log.Info("SUCCEEDED. MAYBE. try it again get go.sum requirements")
|
log.Info("SUCCEEDED. MAYBE. try it again get go.sum requirements")
|
||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
|
@ -297,17 +300,17 @@ func buttonEnable() {
|
||||||
me.Enable()
|
me.Enable()
|
||||||
}
|
}
|
||||||
|
|
||||||
func setCurrentRepo(newcur *repo, s string, note string) bool {
|
func setCurrentRepo(newcur *repolist.Repo, s string, note string) bool {
|
||||||
if newcur.status.ReadOnly() {
|
if newcur.ReadOnly() {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
release.repo.SetValue(newcur.status.String())
|
release.repo.SetText(newcur.GoPath())
|
||||||
release.status.SetValue(s)
|
release.status.SetText(s)
|
||||||
release.notes.SetValue(note)
|
release.notes.SetText(note)
|
||||||
release.current = newcur
|
release.current = newcur
|
||||||
release.version.SetText(release.current.targetVersion.String())
|
release.version.SetText(release.current.Status.GetTargetVersion())
|
||||||
release.releaseVersionB.SetText("release version " + release.current.targetVersion.String())
|
release.releaseVersionB.SetText("release version " + release.current.Status.GetTargetVersion())
|
||||||
// release.unreleaseB.SetText("un-release version " + release.current.targetVersion.String())
|
// release.unreleaseB.SetText("un-release version " + release.current.targetVersion.String())
|
||||||
release.openrepo.Enable()
|
release.openrepo.Enable()
|
||||||
|
|
||||||
|
@ -315,14 +318,14 @@ func setCurrentRepo(newcur *repo, s string, note string) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func scanForReady() bool {
|
func scanForReady() bool {
|
||||||
for _, repo := range me.allrepos {
|
for _, repo := range me.repos.View.AllRepos() {
|
||||||
goSumS := repo.getGoSumStatus()
|
goSumS := repo.GoState()
|
||||||
dirtyS := repo.dirtyLabel.String()
|
dirtyS := repo.State()
|
||||||
log.Info("findNextDirty()", repo.String(), goSumS, dirtyS)
|
log.Info("findNextDirty()", repo.GoPath(), goSumS, dirtyS)
|
||||||
|
|
||||||
if whitelist(repo.String()) {
|
if whitelist(repo.GoPath()) {
|
||||||
log.Info("found WHITELIST", repo.String())
|
log.Info("found WHITELIST", repo.GoPath())
|
||||||
repo.setGoSumStatus("WHITELIST")
|
repo.Status.SetGoSumStatus("WHITELIST")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -334,20 +337,21 @@ func scanForReady() bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// trys to figure out if there is still something to update
|
||||||
|
// todo: redo this logic as it is terrible
|
||||||
func findNextDirty(onlyKind string) bool {
|
func findNextDirty(onlyKind string) bool {
|
||||||
for key := range me.allrepos {
|
for _, repo := range me.repos.View.AllRepos() {
|
||||||
repo := me.allrepos[key]
|
goSumS := repo.Status.GetGoSumStatus()
|
||||||
goSumS := repo.getGoSumStatus()
|
// dirtyS := repo.State()
|
||||||
dirtyS := repo.dirtyLabel.String()
|
|
||||||
|
|
||||||
log.Info("findNextDirty()", repo.String(), goSumS, dirtyS)
|
log.Info("findNextDirty()", repo.GoPath(), goSumS)
|
||||||
if repo.status.ReadOnly() {
|
if repo.ReadOnly() {
|
||||||
log.Info("findNextDirty() skipping readonly")
|
log.Info("findNextDirty() skipping readonly")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if goSumS == "PRIMATIVE" {
|
if goSumS == "PRIMATIVE" {
|
||||||
if setCurrentRepo(repo, "PRIMATIVE", "release new version") {
|
if setCurrentRepo(repo, "PRIMATIVE", "release new version") {
|
||||||
if release.version.String() == release.current.status.GetLastTagVersion() {
|
if release.version.String() == release.current.Status.GetLastTagVersion() {
|
||||||
// everything is fine. the primative has already been released
|
// everything is fine. the primative has already been released
|
||||||
} else {
|
} else {
|
||||||
return true
|
return true
|
||||||
|
@ -369,75 +373,15 @@ func findNextDirty(onlyKind string) bool {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
setCurrentRepo(repo, "REDO GOSUM", "try redoing the gosum")
|
setCurrentRepo(repo, "REDO GOSUM", "try redoing the gosum")
|
||||||
newgoSumS := release.current.getGoSumStatus()
|
newgoSumS := release.current.GoState()
|
||||||
newdirtyS := release.current.dirtyLabel.String()
|
// newdirtyS := release.current.dirtyLabel.String()
|
||||||
newlastS := release.current.status.GetLastTagVersion()
|
newlastS := release.current.LastTag()
|
||||||
if goodCheckGoSum() {
|
if goodCheckGoSum() {
|
||||||
log.Info("findNextDirty() returning true from goodCheckGoSum()", newgoSumS, newgoSumS, newdirtyS, newlastS)
|
log.Info("findNextDirty() returning true from goodCheckGoSum()", newgoSumS, newgoSumS, newlastS)
|
||||||
return true
|
return true
|
||||||
} else {
|
|
||||||
// continue
|
|
||||||
}
|
|
||||||
if repo.String() == "go.wit.com/log" {
|
|
||||||
log.Info("findNextDirty() FOUND LOG", repo.String(), goSumS, dirtyS)
|
|
||||||
log.Info("findNextDirty() FOUND LOG", repo.String(), goSumS, dirtyS)
|
|
||||||
log.Info("findNextDirty() FOUND LOG", repo.String(), goSumS, dirtyS)
|
|
||||||
log.Info("findNextDirty() FOUND LOG", repo.String(), goSumS, dirtyS)
|
|
||||||
log.Info("findNextDirty() FOUND LOG", repo.String(), goSumS, dirtyS)
|
|
||||||
log.Sleep(10)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
continue
|
|
||||||
if goSumS == "UNRELEASED" {
|
|
||||||
if setCurrentRepo(repo, "UNRELEASED", "manually check go.sum") {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if goSumS == "NOT READY" {
|
|
||||||
if setCurrentRepo(repo, "NOT READY", "manually check go.sum") {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if goSumS == "DIRTY 2" {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if goSumS == "BAD DEP" {
|
|
||||||
// find out what kind of BAD DEP?
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
// latestversion := repo.status.GetLastTagVersion()
|
|
||||||
if goSumS == "CLEAN" {
|
|
||||||
// if it's clean here, then check and remake the go.sum file
|
|
||||||
// then stop to commit the release version
|
|
||||||
repo.checkSafeGoSumRemake()
|
|
||||||
if repo.checkDirty() {
|
|
||||||
dirtyS = repo.dirtyLabel.String()
|
|
||||||
}
|
|
||||||
if dirtyS == "PERFECT" {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if setCurrentRepo(repo, "clean", "check manually") {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if goSumS == "DIRTY" {
|
|
||||||
if ok, missing := repo.status.CheckGoSum(); ok {
|
|
||||||
log.Info("repo has go.sum requirements that are clean")
|
|
||||||
// repo.setGoSumStatus("CLEAN")
|
|
||||||
} else {
|
|
||||||
log.Info("DIRTY 2 repo has go.sum requirements that are screwed up. missing:", missing)
|
|
||||||
repo.setGoSumStatus("DIRTY 2")
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if setCurrentRepo(repo, "dirty", "commit changes") {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.Info("tried to findNextDirty() but not sure what to do next")
|
log.Info("tried to findNextDirty() but not sure what to do next")
|
||||||
release.status.SetValue("ALL DONE?")
|
release.status.SetText("ALL DONE?")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
167
repolist.go
167
repolist.go
|
@ -1,167 +0,0 @@
|
||||||
// This is a simple example
|
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"io/ioutil"
|
|
||||||
"os/user"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"go.wit.com/gui"
|
|
||||||
"go.wit.com/lib/gadgets"
|
|
||||||
"go.wit.com/lib/gui/repostatus"
|
|
||||||
"go.wit.com/log"
|
|
||||||
)
|
|
||||||
|
|
||||||
func (r *repo) String() string {
|
|
||||||
if r.status == nil {
|
|
||||||
return r.path
|
|
||||||
}
|
|
||||||
return r.status.String()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *repo) getPath() string {
|
|
||||||
return r.path
|
|
||||||
}
|
|
||||||
|
|
||||||
func RemoveFirstElement(slice []string) (string, []string) {
|
|
||||||
if len(slice) == 0 {
|
|
||||||
return "", slice // Return the original slice if it's empty
|
|
||||||
}
|
|
||||||
return slice[0], slice[1:] // Return the slice without the first element
|
|
||||||
}
|
|
||||||
|
|
||||||
// returns path, master branch name, devel branch name, user branch name
|
|
||||||
func splitLine(line string) (string, string, string, string) {
|
|
||||||
var path, master, devel, user string
|
|
||||||
parts := strings.Split(line, " ")
|
|
||||||
path, parts = RemoveFirstElement(parts)
|
|
||||||
master, parts = RemoveFirstElement(parts)
|
|
||||||
devel, parts = RemoveFirstElement(parts)
|
|
||||||
user, parts = RemoveFirstElement(parts)
|
|
||||||
// path, master, devel, user := strings.Split(line, " ")
|
|
||||||
return path, master, devel, user
|
|
||||||
}
|
|
||||||
|
|
||||||
func myrepolist() []string {
|
|
||||||
content, _ := ioutil.ReadFile("/home/jcarr/.config/myrepolist")
|
|
||||||
out := string(content)
|
|
||||||
out = strings.TrimSpace(out)
|
|
||||||
lines := strings.Split(out, "\n")
|
|
||||||
return lines
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *repo) Hide() {
|
|
||||||
r.pLabel.Hide()
|
|
||||||
r.lastTag.Hide()
|
|
||||||
r.vLabel.Hide()
|
|
||||||
r.targetVersion.Hide()
|
|
||||||
|
|
||||||
r.dirtyLabel.Hide()
|
|
||||||
r.goSumStatus.Hide()
|
|
||||||
r.statusButton.Hide()
|
|
||||||
r.hidden = true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *repo) Show() {
|
|
||||||
r.pLabel.Show()
|
|
||||||
r.lastTag.Show()
|
|
||||||
r.vLabel.Show()
|
|
||||||
r.targetVersion.Show()
|
|
||||||
|
|
||||||
r.dirtyLabel.Show()
|
|
||||||
r.goSumStatus.Show()
|
|
||||||
r.statusButton.Show()
|
|
||||||
r.hidden = false
|
|
||||||
}
|
|
||||||
|
|
||||||
// This creates a window
|
|
||||||
func repoworld() {
|
|
||||||
reposwin = gadgets.NewBasicWindow(me.myGui, "All git repositories in ~/go/src/")
|
|
||||||
reposwin.Make()
|
|
||||||
reposwin.Custom = func() {
|
|
||||||
log.Warn("GOT HERE: main() gadgets.NewBasicWindow() close")
|
|
||||||
log.Warn("Should I do something special here?")
|
|
||||||
}
|
|
||||||
reposbox = reposwin.Box().NewBox("bw vbox", false)
|
|
||||||
|
|
||||||
reposgroup = reposbox.NewGroup("go repositories (read from ~/.config/myrepolist)")
|
|
||||||
reposgrid = reposgroup.NewGrid("test", 7, 1)
|
|
||||||
|
|
||||||
reposgrid.NewLabel("") // path goes here
|
|
||||||
|
|
||||||
reposgrid.NewLabel("last tag")
|
|
||||||
reposgrid.NewLabel("Current Ver")
|
|
||||||
reposgrid.NewLabel("Target Ver")
|
|
||||||
|
|
||||||
reposgrid.NewLabel("Status")
|
|
||||||
reposgrid.NewLabel("go.sum")
|
|
||||||
|
|
||||||
reposgrid.NewLabel("Show()")
|
|
||||||
|
|
||||||
repos := myrepolist()
|
|
||||||
for _, line := range repos {
|
|
||||||
log.Verbose("repo =", line)
|
|
||||||
path, mbranch, dbranch, ubranch := splitLine(line)
|
|
||||||
if mbranch == "" {
|
|
||||||
mbranch = "master"
|
|
||||||
}
|
|
||||||
if dbranch == "" {
|
|
||||||
dbranch = "devel"
|
|
||||||
}
|
|
||||||
usr, _ := user.Current()
|
|
||||||
if ubranch == "" {
|
|
||||||
ubranch = usr.Username
|
|
||||||
}
|
|
||||||
addRepo(reposgrid, path, mbranch, dbranch, ubranch)
|
|
||||||
}
|
|
||||||
|
|
||||||
for i, path := range repostatus.ListGitDirectories() {
|
|
||||||
// log.Info("addRepo()", i, path)
|
|
||||||
tmp := strings.TrimPrefix(path, "/home/jcarr/go/src/")
|
|
||||||
log.Info("addRepo()", i, tmp)
|
|
||||||
addRepo(reposgrid, tmp, "master", "master", "master")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func addRepo(grid *gui.Node, path string, master string, devel string, user string) {
|
|
||||||
_, ok := me.allrepos[path]
|
|
||||||
if ok {
|
|
||||||
log.Info("addRepo() already had path", path)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
newRepo := new(repo)
|
|
||||||
|
|
||||||
if path == "" {
|
|
||||||
log.Warn("addRepo() got empty path", path, master, devel, user)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
newRepo.path = path
|
|
||||||
newRepo.pLabel = grid.NewLabel(path)
|
|
||||||
|
|
||||||
newRepo.lastTag = grid.NewLabel("")
|
|
||||||
newRepo.vLabel = grid.NewLabel("")
|
|
||||||
newRepo.targetVersion = grid.NewLabel("")
|
|
||||||
|
|
||||||
newRepo.dirtyLabel = grid.NewLabel("")
|
|
||||||
newRepo.goSumStatus = grid.NewLabel("?")
|
|
||||||
|
|
||||||
newRepo.statusButton = grid.NewButton("Configure", func() {
|
|
||||||
if newRepo.status == nil {
|
|
||||||
log.Warn("status window doesn't exist")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.Warn("status window exists. trying TestDraw() here")
|
|
||||||
newRepo.status.Toggle()
|
|
||||||
setCurrentRepo(newRepo, "manually chosen", "notsure")
|
|
||||||
})
|
|
||||||
|
|
||||||
newRepo.status = repostatus.NewRepoStatusWindow(newRepo.path)
|
|
||||||
if newRepo.status == nil {
|
|
||||||
log.Warn("something is wrong with", path)
|
|
||||||
os.Exit(0)
|
|
||||||
}
|
|
||||||
newRepo.hidden = false
|
|
||||||
me.allrepos[path] = newRepo
|
|
||||||
}
|
|
|
@ -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("All git repositories in ~/go/src/")
|
||||||
|
r.win.Make()
|
||||||
|
|
||||||
|
r.box = r.win.Box().NewBox("bw vbox", false)
|
||||||
|
// me.reposwin.Draw()
|
||||||
|
r.win.Custom = func() {
|
||||||
|
log.Warn("GOT HERE: main() gadgets.NewBasicWindow() close")
|
||||||
|
log.Warn("Should I do something special here?")
|
||||||
|
}
|
||||||
|
|
||||||
|
r.repoAllButtons()
|
||||||
|
|
||||||
|
r.View = repolist.GuireleaserView(r.box)
|
||||||
|
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *repoWindow) repoAllButtons() {
|
||||||
|
// reposbox.SetExpand(false)
|
||||||
|
group1 := r.box.NewGroup("Run on all repos:")
|
||||||
|
|
||||||
|
hbox := group1.Box()
|
||||||
|
// hbox.Horizontal()
|
||||||
|
hbox.Vertical()
|
||||||
|
|
||||||
|
box2 := hbox.Box().Vertical()
|
||||||
|
box2.NewButton("something", func() {
|
||||||
|
r.Disable()
|
||||||
|
r.Enable()
|
||||||
|
})
|
||||||
|
}
|
88
scan.go
88
scan.go
|
@ -1,88 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"strings"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"go.wit.com/log"
|
|
||||||
)
|
|
||||||
|
|
||||||
func scanRepositories() {
|
|
||||||
var i int = 0
|
|
||||||
t := timeFunction(func() {
|
|
||||||
for _, repo := range me.allrepos {
|
|
||||||
repo.newScan()
|
|
||||||
i += 1
|
|
||||||
}
|
|
||||||
})
|
|
||||||
s := fmt.Sprint(t)
|
|
||||||
log.Info("Scanned", i, "repositories. todo: count/show changes", s)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *repo) newScan() bool {
|
|
||||||
if r.status == nil {
|
|
||||||
log.Warn("repo.status = nil. not initialized for some reason")
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// first run the repostatus update
|
|
||||||
r.status.UpdateNew()
|
|
||||||
|
|
||||||
// now read those values and display them in our table
|
|
||||||
// mname := r.status.GetMasterBranchName()
|
|
||||||
// mver := r.status.GetMasterVersion()
|
|
||||||
// mver = mver + " (" + mname + ")"
|
|
||||||
// r.masterVersion.SetLabel(mver)
|
|
||||||
|
|
||||||
cbname := r.status.GetCurrentBranchName()
|
|
||||||
cbversion := r.status.GetCurrentBranchVersion()
|
|
||||||
lasttag := r.status.GetLastTagVersion()
|
|
||||||
r.lastTag.SetLabel(lasttag)
|
|
||||||
r.vLabel.SetLabel(cbname + " " + cbversion)
|
|
||||||
|
|
||||||
if c, ok := r.status.Changed(); ok {
|
|
||||||
c := strings.TrimSpace(c)
|
|
||||||
for _, line := range strings.Split(c, "\n") {
|
|
||||||
log.Info(r.status.Path(), line)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
status := r.status.GetStatus()
|
|
||||||
r.dirtyLabel.SetLabel(status)
|
|
||||||
if status == "PERFECT" {
|
|
||||||
if me.autoHidePerfect.Checked() {
|
|
||||||
r.Hide()
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// timeFunction takes a function as an argument and returns the execution time.
|
|
||||||
func timeFunction(f func()) time.Duration {
|
|
||||||
startTime := time.Now() // Record the start time
|
|
||||||
f() // Execute the function
|
|
||||||
return time.Since(startTime) // Calculate the elapsed time
|
|
||||||
}
|
|
||||||
|
|
||||||
func myTicker(t time.Duration, name string, f func()) {
|
|
||||||
ticker := time.NewTicker(t)
|
|
||||||
defer ticker.Stop()
|
|
||||||
done := make(chan bool)
|
|
||||||
/*
|
|
||||||
go func() {
|
|
||||||
time.Sleep(10 * time.Second)
|
|
||||||
done <- true
|
|
||||||
}()
|
|
||||||
*/
|
|
||||||
for {
|
|
||||||
select {
|
|
||||||
case <-done:
|
|
||||||
fmt.Println("Done!")
|
|
||||||
return
|
|
||||||
case t := <-ticker.C:
|
|
||||||
log.Verbose(name, "Current time: ", t)
|
|
||||||
f()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
64
scanGoSum.go
64
scanGoSum.go
|
@ -2,61 +2,55 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"go.wit.com/lib/gui/repolist"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (r *repo) getGoSumStatus() string {
|
/*
|
||||||
return r.goSumStatus.String()
|
func getGoSumStatus(r *repolist.Repo) string {
|
||||||
|
return r.Status.GoSumStatus.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *repo) setGoSumStatus(s string) {
|
func setGoSumStatus(r *repolist.Repo, s string) {
|
||||||
r.goSumStatus.SetLabel(s)
|
r.goSumStatus.SetLabel(s)
|
||||||
r.status.SetGoSumStatus(s)
|
r.status.SetGoSumStatus(s)
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
func (r *repo) checkDirty() bool {
|
func checkSafeGoSumRemake(r *repolist.Repo) {
|
||||||
if r.status.CheckDirty() {
|
if ok, bad := r.Status.CheckSafeGoSumRemake(); ok {
|
||||||
log.Info("dirty repo:", r.status.String(), r.getGoSumStatus())
|
|
||||||
r.setGoSumStatus("DIRTY")
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *repo) checkSafeGoSumRemake() {
|
|
||||||
if ok, bad := r.status.CheckSafeGoSumRemake(); ok {
|
|
||||||
log.Info("checkSafeGoSumRemake() is safe to redo")
|
log.Info("checkSafeGoSumRemake() is safe to redo")
|
||||||
r.setGoSumStatus("SAFE")
|
r.Status.SetGoSumStatus("SAFE")
|
||||||
r.status.MakeRedomod()
|
r.Status.MakeRedomod()
|
||||||
} else {
|
} else {
|
||||||
log.Info("checkSafeGoSumRemake() is not safe. problems:", bad)
|
log.Info("checkSafeGoSumRemake() is not safe. problems:", bad)
|
||||||
r.setGoSumStatus("BAD DEP")
|
r.Status.SetGoSumStatus("BAD DEP")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func scanGoSum() {
|
func scanGoSum() {
|
||||||
for _, repo := range me.allrepos {
|
for _, repo := range me.repos.View.AllRepos() {
|
||||||
if repo.String() == "go.wit.com/apps/guireleaser" {
|
if repo.GoPath() == "go.wit.com/apps/guireleaser" {
|
||||||
if release.guireleaser == nil {
|
if release.guireleaser == nil {
|
||||||
release.guireleaser = repo
|
release.guireleaser = repo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
latestversion := repo.status.GetLastTagVersion()
|
latestversion := repo.Status.GetLastTagVersion()
|
||||||
if repo.getGoSumStatus() == "BAD" {
|
if repo.GoState() == "BAD" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if repo.getGoSumStatus() == "DIRTY" {
|
if repo.GoState() == "DIRTY" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if repo.status.CheckPrimativeGoMod() {
|
if repo.Status.CheckPrimativeGoMod() {
|
||||||
log.Info("PRIMATIVE repo:", latestversion, repo.status.String())
|
log.Info("PRIMATIVE repo:", latestversion, repo.GoPath())
|
||||||
repo.setGoSumStatus("PRIMATIVE")
|
repo.SetGoState("PRIMATIVE")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if repo.checkDirty() {
|
if repo.CheckDirty() {
|
||||||
log.Info("dirty repo:", latestversion, repo.status.String())
|
log.Info("dirty repo:", latestversion, repo.GoPath())
|
||||||
log.Info("dirty repo.getGoSumStatus =", repo.getGoSumStatus())
|
log.Info("dirty repo.getGoSumStatus =", repo.GoState())
|
||||||
repo.setGoSumStatus("DIRTY")
|
repo.SetGoState("DIRTY")
|
||||||
|
|
||||||
// release.repo.SetValue(repo.status.String())
|
// release.repo.SetValue(repo.status.String())
|
||||||
// release.status.SetValue("dirty")
|
// release.status.SetValue("dirty")
|
||||||
|
@ -65,12 +59,12 @@ func scanGoSum() {
|
||||||
// release.openrepo.Enable()
|
// release.openrepo.Enable()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if ok, missing := repo.status.CheckGoSum(); ok {
|
if ok, missing := repo.Status.CheckGoSum(); ok {
|
||||||
log.Info("repo has go.sum requirements that are clean")
|
log.Info("repo has go.sum requirements that are clean")
|
||||||
repo.setGoSumStatus("CLEAN")
|
repo.SetGoState("CLEAN")
|
||||||
} else {
|
} else {
|
||||||
log.Info("repo has go.sum requirements that are screwed up. missing:", missing)
|
log.Info("repo has go.sum requirements that are screwed up. missing:", missing)
|
||||||
repo.setGoSumStatus("BAD")
|
repo.SetGoState("BAD")
|
||||||
|
|
||||||
// release.repo.SetValue(repo.status.String())
|
// release.repo.SetValue(repo.status.String())
|
||||||
// release.status.SetValue("bad")
|
// release.status.SetValue("bad")
|
||||||
|
@ -79,14 +73,14 @@ func scanGoSum() {
|
||||||
// release.openrepo.Enable()
|
// release.openrepo.Enable()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
status := repo.dirtyLabel.String()
|
status := repo.State()
|
||||||
if status == "PERFECT" {
|
if status == "PERFECT" {
|
||||||
continue
|
continue
|
||||||
} else {
|
} else {
|
||||||
repo.newScan()
|
repo.NewScan()
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Info("repo:", latestversion, status, repo.status.String())
|
log.Info("repo:", latestversion, status, repo.GoPath())
|
||||||
}
|
}
|
||||||
log.Info("scanGoSum() did everything, not sure what to do next")
|
log.Info("scanGoSum() did everything, not sure what to do next")
|
||||||
}
|
}
|
||||||
|
|
15
structs.go
15
structs.go
|
@ -4,11 +4,10 @@ package main
|
||||||
import (
|
import (
|
||||||
"go.wit.com/gui"
|
"go.wit.com/gui"
|
||||||
"go.wit.com/lib/gadgets"
|
"go.wit.com/lib/gadgets"
|
||||||
"go.wit.com/lib/gui/repostatus"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// the main window nodes
|
// the main window nodes
|
||||||
var reposwin *gadgets.BasicWindow
|
// var reposwin *gadgets.BasicWindow
|
||||||
var reposbox *gui.Node
|
var reposbox *gui.Node
|
||||||
var reposgrid *gui.Node
|
var reposgrid *gui.Node
|
||||||
var reposgroup *gui.Node
|
var reposgroup *gui.Node
|
||||||
|
@ -16,15 +15,17 @@ var reposgroup *gui.Node
|
||||||
var me *autoType
|
var me *autoType
|
||||||
|
|
||||||
type autoType struct {
|
type autoType struct {
|
||||||
allrepos map[string]*repo
|
|
||||||
myGui *gui.Node
|
myGui *gui.Node
|
||||||
|
|
||||||
releaseReasonS string // = "gocui dropdown select"
|
releaseReasonS string // = "gocui dropdown select"
|
||||||
|
|
||||||
// autotypistWindow *gadgets.BasicWindow
|
// guireleaser window
|
||||||
mainWindow *gui.Node
|
mainWindow *gui.Node
|
||||||
mainBox *gui.Node
|
mainBox *gui.Node
|
||||||
|
|
||||||
|
// our view of the repositories
|
||||||
|
repos *repoWindow
|
||||||
|
|
||||||
// #### autotypist Global Display Options
|
// #### autotypist Global Display Options
|
||||||
autoHidePerfect *gui.Node
|
autoHidePerfect *gui.Node
|
||||||
autoHideReadOnly *gui.Node
|
autoHideReadOnly *gui.Node
|
||||||
|
@ -77,12 +78,17 @@ type autoType struct {
|
||||||
setBranchesToMasterB *gui.Node
|
setBranchesToMasterB *gui.Node
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (my *autoType) GoSrcPath() string {
|
||||||
|
return my.goSrcPwd.String()
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
var cmds *gui.Node
|
var cmds *gui.Node
|
||||||
var doit *gui.Node
|
var doit *gui.Node
|
||||||
var dryrun *gui.Node
|
var dryrun *gui.Node
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
type repo struct {
|
type repo struct {
|
||||||
hidden bool
|
hidden bool
|
||||||
path string
|
path string
|
||||||
|
@ -104,3 +110,4 @@ type repo struct {
|
||||||
|
|
||||||
status *repostatus.RepoStatus
|
status *repostatus.RepoStatus
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
10
whitelist.go
10
whitelist.go
|
@ -3,13 +3,15 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"go.wit.com/lib/gui/repolist"
|
||||||
)
|
)
|
||||||
|
|
||||||
func initWhitelist() {
|
func initWhitelist() {
|
||||||
release.whitelist = make(map[string]*repo)
|
release.whitelist = make(map[string]*repolist.Repo)
|
||||||
for _, repo := range me.allrepos {
|
for _, repo := range me.repos.View.AllRepos() {
|
||||||
if strings.HasPrefix(repo.String(), "go.wit.com/dev/davecgh") {
|
if strings.HasPrefix(repo.GoPath(), "go.wit.com/dev/davecgh") {
|
||||||
release.whitelist[repo.String()] = repo
|
release.whitelist[repo.GoPath()] = repo
|
||||||
}
|
}
|
||||||
// if repo.String() == "go.wit.com/apps/guireleaser" {
|
// if repo.String() == "go.wit.com/apps/guireleaser" {
|
||||||
// release.whitelist[repo.String()] = repo
|
// release.whitelist[repo.String()] = repo
|
||||||
|
|
Loading…
Reference in New Issue