got a temp window to work as a workaround

This commit is contained in:
Jeff Carr 2024-11-05 01:44:24 -06:00
parent d3cc4d6a15
commit a72c700f63
8 changed files with 169 additions and 284 deletions

View File

@ -10,9 +10,16 @@ all: build
# single-really-do-it: build
# ./guireleaser go.wit.com/apps/go-clone --increment --release --reason "testing guireleaser"
# stderr: build
# echo "writing to /tmp/guireleaser.stderr"
# ./guireleaser >/tmp/guireleaser.stderr 2>&1
stderr: build
echo "writing to /tmp/guireleaser.stderr"
./guireleaser >/tmp/guireleaser.stderr 2>&1
do-release:
make curl-release-list
make curl-incrementAllTargetVersions
make curl-release-list
make curl-findNext
make curl-showNext
goimports:
goimports -w *.go
@ -42,6 +49,9 @@ redomod:
curl-help:
curl --silent http://localhost:9419/help
curl-tempWin:
curl --silent http://localhost:9419/tempWin
curl-setBranchesToMasterB:
curl --silent http://localhost:9419/setBranchesToMasterB
@ -52,8 +62,14 @@ curl-findNext:
curl-showNext:
curl --silent http://localhost:9419/showNext
curl-setTargetVersion:
curl --silent http://localhost:9419/setTargetVersion?version=v0.22.5
curl-doRelease:
curl --silent http://localhost:9419/doRelease
curl-setTargetVersion-virtigo-v0.1.1:
curl --silent http://localhost:9419/setTargetVersion?version=v0.1.1
curl-incrementAllTargetVersions:
curl --silent http://localhost:9419/setAllTargetVersions
curl-IncrementMinorVersion:
curl --silent http://localhost:9419/IncrementMinorVersion?repo=go.wit.com/toolkit/debian
@ -63,7 +79,7 @@ curl-IncrementRevisonVersion:
# report on the release
curl-release-list:
curl --silent http://localhost:9419/releaselist?readonly=true
curl --silent http://localhost:9419/releaseList?readonly=true
#curl-doSingleRepo:
# curl --silent 'http://localhost:9419/doSingleRepo?repo=go.wit.com/gui&dryrun=false'

View File

@ -7,7 +7,7 @@ package main
*/
type argv struct {
Repo string `arg:"positional" help:"go import path"`
// 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"`

View File

@ -1,73 +0,0 @@
package main
import (
"os"
"go.wit.com/lib/gui/repolist"
"go.wit.com/log"
)
func doSingleRepo(myRepoName string) {
// the repo from the command line
var myrepo *repolist.RepoRow
// find myself. the guireleaser directory is used as a working scratchpad
// for running go commands that can mess up the go.* files
// for _, repo := range me.repos.View.AllRepos() {
myrepo = me.repos.View.FindRepoByName(myRepoName)
me.mainWindow.Disable()
defer me.mainWindow.Enable()
if myrepo == nil {
log.Info("could not find", myargs.Repo)
}
log.Info("only going to do repo:", myrepo.GoPath())
tmp := myargs.Reason
if tmp == "" {
tmp = os.Getenv("GUIRELEASE_REASON")
}
if tmp == "" {
tmp = "made by guireleaser"
}
// increment all the versions
for _, repo := range me.repos.View.AllRepos() {
if whitelist(repo.GoPath()) {
continue
}
if repo.ReadOnly() {
continue
}
lasttag := repo.Status.LastTag()
if repo.Status.GetCurrentVersion() == lasttag {
log.Info("skipping unchanged repo", repo.Status.GoPath())
repo.Status.SetTargetVersion(lasttag)
continue
}
repo.Status.IncrementRevisionVersion("go-clone")
}
// rescan all the repos
me.repos.View.ScanRepositories()
myrepo.Status.MakeRedomod()
myrepo.Status.IncrementRevisionVersion(tmp)
_, err := me.repos.View.CheckValidGoSum(myrepo)
if err != nil {
log.Info("go mod tidy not ok", err)
return
}
if !checkValidGoSum(myrepo) {
log.Info("go.sum checks failed")
os.Exit(0)
}
setCurrentRepo(myrepo, "should be good to release", "pretty sure")
log.Info("DO THE RELEASE HERE")
log.Info("going to release", myrepo.GoPath(), "as version", myrepo.Status.GetTargetVersion())
if myargs.DryRun {
log.Info("--dry-run == true")
} else {
log.Info("--dry-run == true")
// doRelease()
}
}

180
http.go
View File

@ -6,7 +6,6 @@ import (
"os"
"strings"
"go.wit.com/lib/gui/gowit"
"go.wit.com/log"
)
@ -26,37 +25,40 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
var route string
route = cleanURL(r.URL.Path)
if route == "/help" {
switch route {
case "/help":
msg(w, "list/ list modified repos")
msg(w, "list?readonly=true shows every repo")
msg(w, "")
msg(w, "setBranchesToMasterB maybe this sets everything to master?")
msg(w, "doSingleRepo?repo=go.wit.com/gui attempts to release gui")
msg(w, "doRelease runs doRelease()")
msg(w, "findNext runs findNext()")
msg(w, "showNext shows the repo for doRelease()")
msg(w, "setTargetVersion set the target version for findNext()")
msg(w, "setAllTargetVersions?version=v0.12.4 set ever repo to target version")
msg(w, "setCurrentRepo?repo=go.wit.com/gui runs setCurrentRepo(repo)")
msg(w, "")
msg(w, "setAllBranchesToMaster git checkout master on every repo")
msg(w, "")
msg(w, "setVersion?repo=go.wit.com/gui?target=0.2 attempts to set the target version to 0.2")
msg(w, "")
return
case "/tempWin":
tempWin := makeTempView()
loop := me.repos.View.UnmergedRepos()
for loop.Scan() {
repo := loop.Repo()
tempWin.View.ShowRepo(repo)
msg(w, "UnmergedRepo: " + repo.Name())
}
if route == "/release" {
// simpleRelease(w, r)
return
case "/doRelease":
buttonDisable()
if doRelease() {
buttonEnable()
msg(w, "doRelease() worked")
} else {
msg(w, "doRelease() failed")
}
if route == "/gitpull" {
return
}
if route == "/list" {
readonly := r.URL.Query().Get("readonly")
onlydirty := r.URL.Query().Get("onlydirty")
perfect := r.URL.Query().Get("perfect")
me.repos.View.PrintReport(w, readonly, onlydirty, perfect)
return
}
if route == "/findNext" {
case "/findNext":
me.Disable()
defer me.Enable()
if findNext() {
@ -71,10 +73,7 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
msg(w, me.current.StandardHeader())
msg(w, me.current.StandardReleaseHeader())
return
}
if route == "/setCurrentRepo" {
case "/setCurrentRepo":
repoName := r.URL.Query().Get("repo")
version := r.URL.Query().Get("version")
comment := r.URL.Query().Get("comment")
@ -90,9 +89,7 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
}
setCurrentRepo(repo, "HTTP", "doRelease() ?")
}
if route == "/IncrementRevisonVersion" {
case "/IncrementRevisonVersion":
repo := r.URL.Query().Get("repo")
version := r.URL.Query().Get("version")
comment := r.URL.Query().Get("comment")
@ -101,10 +98,7 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
msg(w, "version: "+version)
me.current.Status.IncrementRevisionVersion(comment)
return
}
if route == "/IncrementMinorVersion" {
case "/IncrementMinorVersion":
repo := r.URL.Query().Get("repo")
version := r.URL.Query().Get("version")
@ -112,49 +106,7 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
msg(w, "version: "+version)
me.current.Status.IncrementMinorVersion("trying minor")
return
}
if route == "/setTargetVersion" {
version := r.URL.Query().Get("version")
repo := r.URL.Query().Get("repo")
msg(w, "repo: "+repo)
msg(w, "version: "+version)
me.current.Status.SetTargetVersion(version)
return
}
if route == "/showNext" {
msg(w, "repo: "+me.release.repo.String())
msg(w, "name: "+me.release.version.String())
msg(w, "notes: "+me.release.notes.String())
msg(w, "status: "+me.release.status.String())
if checkValidGoSum(me.current) {
msg(w, "checkValidGoSum() == true")
} else {
msg(w, "checkValidGoSum() == false")
}
msg(w, me.current.StandardHeader())
msg(w, me.current.StandardReleaseHeader())
return
}
if route == "/releaselist" {
readonly := r.URL.Query().Get("readonly")
perfect := r.URL.Query().Get("perfect")
me.repos.View.PrintReleaseReport(w, readonly, perfect)
return
}
if route == "/goweblist" {
gowit.DumpVersions(me.repos.View)
return
}
if route == "/setBranchesToMasterB" {
case "/setAllBranchesToMaster":
msg(w, "set all branches to master")
me.Disable()
defer me.Enable()
@ -163,21 +115,71 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
me.setBranchesToMasterB.Disable()
}
return
}
case "/setTargetVersion":
version := r.URL.Query().Get("version")
repo := r.URL.Query().Get("repo")
if route == "/doSingleRepo" {
reponame := r.URL.Query().Get("repo")
msg(w, "doSingleRepo: "+reponame)
doSingleRepo(reponame)
}
if route == "/quit" {
os.Exit(0)
msg(w, "repo: "+repo)
msg(w, "version: "+version)
if me.current == nil {
msg(w, "me.current == nil")
return
}
me.current.Status.SetTargetVersion(version)
case "/setAllTargetVersions":
version := r.URL.Query().Get("version")
msg(w, "version: "+version)
log.Warn("BAD URL =", route)
fmt.Fprintln(w, "BAD URL =", route)
loop := me.repos.View.ReposSortByName()
for loop.Scan() {
repo := loop.Repo()
master := repo.Status.GetMasterVersion()
cur := repo.Status.GetCurrentVersion()
if master == cur {
repo.Status.SetTargetVersion(cur)
} else {
repo.Status.IncrementRevisionVersion("Nov 2024 test")
}
}
case "/showNext":
msg(w, "gui repo: "+me.release.repo.String())
msg(w, "gui name: "+me.release.version.String())
msg(w, "gui notes: "+me.release.notes.String())
msg(w, "gui status: "+me.release.status.String())
msg(w, "")
if checkValidGoSum(me.current) {
msg(w, "checkValidGoSum() == true")
} else {
msg(w, "checkValidGoSum() == false")
}
if me.current.Status.IsReleased() {
msg(w, "IsReleased() == true")
} else {
msg(w, "IsReleased() == false")
}
msg(w, "")
msg(w, me.current.StandardHeader())
msg(w, me.current.StandardReleaseHeader())
case "/list":
readonly := r.URL.Query().Get("readonly")
onlydirty := r.URL.Query().Get("onlydirty")
perfect := r.URL.Query().Get("perfect")
me.repos.View.PrintReport(w, readonly, onlydirty, perfect)
case "/releaseList":
readonly := r.URL.Query().Get("readonly")
perfect := r.URL.Query().Get("perfect")
me.repos.View.PrintReleaseReport(w, readonly, perfect)
case "/quit":
msg(w, "Got URL /quit")
os.Exit(0)
default:
msg(w, "BAD URL = "+route)
}
}
// starts and sits waiting for HTTP requests

View File

@ -21,3 +21,15 @@ func (r *repoWindow) initRepoList() {
r.View.NewRepo(path)
}
}
func (r *repoWindow) tmpRepoList() {
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.NewRepo(path)
}
}

60
main.go
View File

@ -91,7 +91,7 @@ func main() {
// parse config file and scan for .git repos
me.repos.initRepoList()
setTargetVersion()
// setTargetVersion()
// register a Show/Hide function for the repo list table
me.repos.View.RegisterHideFunction(hideFunction)
@ -118,64 +118,6 @@ func main() {
*/
}
/*
if myargs.Repo != "" {
me.mainWindow.Hide()
if myrepo == nil {
log.Info("could not find", myargs.Repo)
os.Exit(0)
}
log.Info("only going to do repo:", myrepo.GoPath())
tmp := myargs.Reason
if tmp == "" {
tmp = os.Getenv("GUIRELEASE_REASON")
}
if tmp == "" {
tmp = "made by guireleaser"
}
// increment all the versions
for _, repo := range me.repos.View.AllRepos() {
if whitelist(repo.GoPath()) {
continue
}
if repo.ReadOnly() {
continue
}
lasttag := repo.Status.LastTag()
if repo.Status.GetCurrentVersion() == lasttag {
log.Info("skipping unchanged repo", repo.Status.GoPath())
repo.Status.SetTargetVersion(lasttag)
continue
}
repo.Status.IncrementRevisionVersion("go-clone")
}
// rescan all the repos
me.repos.View.ScanRepositories()
myrepo.Status.MakeRedomod()
myrepo.Status.IncrementRevisionVersion(tmp)
_, err := me.repos.View.CheckValidGoSum(myrepo)
if err != nil {
log.Info("go mod tidy not ok", err)
return
}
if !checkValidGoSum(myrepo) {
log.Info("go.sum checks failed")
os.Exit(0)
}
setCurrentRepo(myrepo, "should be good to release", "pretty sure")
log.Info("DO THE RELEASE HERE")
log.Info("going to release", myrepo.GoPath(), "as version", myrepo.Status.GetTargetVersion())
if myargs.DryRun {
log.Info("--dry-run == true")
} else {
doRelease()
}
os.Exit(0)
}
*/
if me.release.guireleaser == nil {
log.Info("Can not release if guireleaser was not found")
os.Exit(0)

View File

@ -1,50 +0,0 @@
package main
import (
"os"
"go.wit.com/lib/gui/repostatus"
"go.wit.com/log"
)
func doesExist(path string) bool {
if _, err := os.Stat(path); err != nil {
if os.IsNotExist(err) {
return false
}
}
return true
}
// only errors on bad errors
func quickCmd(fullpath string, cmd []string) bool {
var err error
var b bool
var output string
if me.autoWorkingPwd.String() != fullpath {
me.autoWorkingPwd.SetValue(fullpath)
}
if me.autoDryRun.Checked() {
log.Warn("RUN --dry-run", fullpath, cmd)
return false
} else {
log.Warn("RUN:", fullpath, cmd)
}
err, b, output = repostatus.RunCmd(fullpath, cmd)
if err != nil {
log.Warn("cmd =", cmd)
log.Warn("err =", err)
log.Warn("b =", b)
log.Warn("output =", string(output))
return false
} else if !b {
log.Warn("b =", b)
log.Warn("output =", string(output))
return true
}
log.Warn("output = ", string(output))
return true
}

36
tempView.go Normal file
View File

@ -0,0 +1,36 @@
package main
import (
"go.wit.com/lib/gadgets"
"go.wit.com/lib/gui/repolist"
"go.wit.com/log"
)
func makeTempView() *repoWindow {
r := new(repoWindow)
r.win = gadgets.RawBasicWindow("unmerged repositories")
r.win.Make()
r.box = r.win.Box().NewBox("bw vbox", false)
r.win.Custom = func() {
log.Warn("GOT HERE: makeTempView() close")
log.Warn("GOT HERE: makeTempView() 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()
box2 := hbox.Box().Vertical()
box2.NewButton("reload values", func() {
// gowit.DumpVersions(me.repos.View)
})
r.View = repolist.TempWindowView(r.box)
r.Show()
return r
}