guireleaser/unreleaseWindow.go

80 lines
2.1 KiB
Go

// This is a simple example
package main
import (
"go.wit.com/gui"
"go.wit.com/log"
)
func createUnreleaseBox(box *gui.Node) {
group := release.box.NewGroup("undo and redo things")
group.NewButton("find the unreleased", func() {
me.Disable()
defer me.Enable()
for _, repo := range me.allrepos {
if whitelist(repo.String()) {
log.Info("skipping whitelist", repo.String())
continue
}
if repo.lookToUnwind() {
log.Info("found something to unwind:", repo.String())
if setCurrentRepo(repo, "rewind this", "very sure") {
}
return
}
}
})
group.NewButton("re-release"+release.versionS, func() {
me.Disable()
if release.current.status.CheckDirty() {
log.Info("sorry, it's still dirty")
return
}
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
}
log.Info("\treset to devel", curName, release.versionS, 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", "v" + release.versionS})
all = append(all, []string{"git", "push", "--delete", "origin", "v" + release.versionS})
all = append(all, []string{"git", "tag", "-m", release.reasonS, "v" + release.versionS})
all = append(all, []string{"git", "push", "origin", "v" + release.versionS})
if doAll(release.current, all) {
log.Info("EVERYTHING OK")
me.Enable()
} else {
log.Info("SOMETHING FAILED")
}
})
}
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
}