126 lines
3.2 KiB
Go
126 lines
3.2 KiB
Go
// This is a simple example
|
|
package main
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"go.wit.com/gui"
|
|
"go.wit.com/log"
|
|
)
|
|
|
|
func findUnreleased() bool {
|
|
for _, repo := range me.allrepos {
|
|
if whitelist(repo.String()) {
|
|
log.Info("skipping whitelist", repo.String())
|
|
continue
|
|
}
|
|
setCurrentRepo(repo, "rewind this?", "not sure")
|
|
|
|
if repo.lookToUnwind() {
|
|
log.Info("found something to unwind:", repo.String())
|
|
if setCurrentRepo(repo, "rewind this", "very sure") {
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
func createUnreleaseBox(box *gui.Node) {
|
|
group := release.box.NewGroup("undo and redo things")
|
|
|
|
group.NewButton("find the unreleased", func() {
|
|
me.Disable()
|
|
defer me.Enable()
|
|
findUnreleased()
|
|
})
|
|
release.unreleaseB = group.NewButton("re-release", func() {
|
|
// var count int = 0
|
|
me.Disable()
|
|
if rerelease() {
|
|
log.Info("good to re-release another one")
|
|
} else {
|
|
log.Info("loop(3) failed")
|
|
return
|
|
}
|
|
me.Enable()
|
|
})
|
|
group.NewButton("loop(5)", func() {
|
|
me.Disable()
|
|
for n := 0; n <= 5; n++ {
|
|
if rerelease() {
|
|
log.Info("good to re-release another one")
|
|
} else {
|
|
log.Info("loop(3) failed")
|
|
return
|
|
}
|
|
}
|
|
log.Info("loop(5) worked")
|
|
me.Enable()
|
|
})
|
|
}
|
|
|
|
func doAll(r *repo, all [][]string) bool {
|
|
for _, cmd := range all {
|
|
log.Info("doAll() RUNNING: cmd =", cmd)
|
|
err, out := r.status.RunCmd(cmd)
|
|
log.Info("doAll() err =", err)
|
|
log.Info("doAll() out =", out)
|
|
if err != nil {
|
|
return false
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
func rerelease() bool {
|
|
if release.unreleaseB.String() != "un-release version "+release.version.String() {
|
|
log.Warn("something went wrong with the release.version:", release.version.String())
|
|
return false
|
|
}
|
|
|
|
if strings.HasPrefix(release.version.String(), "v") {
|
|
log.Warn("everything is ok. version starts with v.", release.version.String())
|
|
} else {
|
|
log.Warn("version does not start with v.", release.version.String())
|
|
return false
|
|
}
|
|
|
|
if release.current.status.CheckDirty() {
|
|
log.Info("sorry, it's still dirty")
|
|
return false
|
|
}
|
|
|
|
curName := release.current.status.GetCurrentBranchName()
|
|
mName := release.current.status.GetMasterBranchName()
|
|
if curName != mName {
|
|
log.Info("\trepo is not working from main branch", curName, "!=", mName)
|
|
return false
|
|
}
|
|
|
|
log.Info("\treset to devel", curName, release.version.String(), release.reasonS)
|
|
|
|
var all [][]string
|
|
all = append(all, []string{"git", "checkout", "devel"})
|
|
all = append(all, []string{"git", "branch", "-D", mName})
|
|
all = append(all, []string{"git", "branch", mName})
|
|
all = append(all, []string{"git", "checkout", mName})
|
|
all = append(all, []string{"git", "push", "--set-upstream", "--force", "origin", mName})
|
|
|
|
all = append(all, []string{"git", "tag", "--delete", release.version.String()})
|
|
all = append(all, []string{"git", "push", "--delete", "origin", release.version.String()})
|
|
all = append(all, []string{"git", "tag", "-m", release.reasonS, release.version.String()})
|
|
all = append(all, []string{"git", "push", "origin", release.version.String()})
|
|
|
|
if doAll(release.current, all) {
|
|
log.Info("EVERYTHING OK. RERELEASED", release.current.String())
|
|
if findUnreleased() {
|
|
log.Info("GOOD TO RUN ANOTHER DAY ON:", release.current.String())
|
|
}
|
|
} else {
|
|
log.Info("SOMETHING FAILED")
|
|
return false
|
|
}
|
|
return true
|
|
}
|