remote msg()

This commit is contained in:
Jeff Carr 2024-11-07 03:32:00 -06:00
parent 9d1b3c0359
commit 66bd2481ae
2 changed files with 87 additions and 84 deletions

View File

@ -174,17 +174,20 @@ func doPublishVersion() bool {
if gopath == "go.wit.com/apps/guireleaser" { if gopath == "go.wit.com/apps/guireleaser" {
log.Info("CAN NOT SELF UPDATE. cmd =", cmd) log.Info("CAN NOT SELF UPDATE. cmd =", cmd)
log.Info("go get must be run from somewhere else other than guireleaser") log.Info("go get must be run from somewhere else other than guireleaser")
log.Info("fix this!") err, ok, output := shell.RunCmd("", cmd)
os.Exit(-1) log.Info("err =", err)
} log.Info("ok =", ok)
// publish go.mod & go.sum for use with go log.Info("output =", output)
os.Unsetenv("GO111MODULE") } else {
log.Info("TRYING TO SELF UPDATE HERE. cmd =", cmd) // publish go.mod & go.sum for use with go
err, out = me.release.guireleaser.Status.RunCmd(cmd) os.Unsetenv("GO111MODULE")
if gopath == "go.wit.com/apps/guireleaser" { log.Info("TRYING TO SELF UPDATE HERE. cmd =", cmd)
// ignore errors on updating myself err, out = me.release.guireleaser.Status.RunCmd(cmd)
log.Info("IGNORE SELF UPDATE ERROR. cmd =", cmd) if gopath == "go.wit.com/apps/guireleaser" {
err = nil // ignore errors on updating myself
log.Info("IGNORE SELF UPDATE ERROR. cmd =", cmd)
err = nil
}
} }
} }
if err == nil { if err == nil {

146
http.go
View File

@ -42,20 +42,20 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
switch route { switch route {
case "/help": case "/help":
msg(w, "list/ list modified repos") log.Info("list/ list modified repos")
msg(w, "list?readonly=true shows every repo") log.Info("list?readonly=true shows every repo")
msg(w, "") log.Info("")
msg(w, "doRelease runs doRelease()") log.Info("doRelease runs doRelease()")
msg(w, "findNext runs findNext()") log.Info("findNext runs findNext()")
msg(w, "showNext shows the repo for doRelease()") log.Info("showNext shows the repo for doRelease()")
msg(w, "setTargetVersion set the target version for findNext()") log.Info("setTargetVersion set the target version for findNext()")
msg(w, "setAllTargetVersions?version=v0.12.4 set ever repo to target version") log.Info("setAllTargetVersions?version=v0.12.4 set ever repo to target version")
msg(w, "setCurrentRepo?repo=go.wit.com/gui runs setCurrentRepo(repo)") log.Info("setCurrentRepo?repo=go.wit.com/gui runs setCurrentRepo(repo)")
msg(w, "") log.Info("")
msg(w, "setAllBranchesToMaster git checkout master on every repo") log.Info("setAllBranchesToMaster git checkout master on every repo")
msg(w, "") log.Info("")
msg(w, "setVersion?repo=go.wit.com/gui?target=0.2 attempts to set the target version to 0.2") log.Info("setVersion?repo=go.wit.com/gui?target=0.2 attempts to set the target version to 0.2")
msg(w, "") log.Info("")
case "/tempWin": case "/tempWin":
tempWin := makeTempView() tempWin := makeTempView()
@ -63,62 +63,62 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
for loop.Scan() { for loop.Scan() {
repo := loop.Repo() repo := loop.Repo()
tempWin.View.ShowRepo(repo) tempWin.View.ShowRepo(repo)
msg(w, "UnmergedRepo: "+repo.Name()) log.Info("UnmergedRepo: "+repo.Name())
} }
case "/doRelease": case "/doRelease":
buttonDisable() buttonDisable()
if doRelease(w) { if doRelease(w) {
buttonEnable() buttonEnable()
msg(w, "doRelease() worked") log.Info("doRelease() worked")
} else { } else {
msg(w, "doRelease() failed") log.Info("doRelease() failed")
} }
case "/findNext": case "/findNext":
me.Disable() me.Disable()
defer me.Enable() defer me.Enable()
if findNext() { if findNext() {
msg(w, "findNext() found a repo") log.Info("findNext() found a repo")
} else { } else {
msg(w, "findNext() did not find a repo. You might be finished?") log.Info("findNext() did not find a repo. You might be finished?")
} }
msg(w, "repo: "+me.release.repo.String()) log.Info("repo: "+me.release.repo.String())
msg(w, "name: "+me.release.version.String()) log.Info("name: "+me.release.version.String())
msg(w, "notes: "+me.release.notes.String()) log.Info("notes: "+me.release.notes.String())
msg(w, "status: "+me.release.status.String()) log.Info("status: "+me.release.status.String())
if me.current == nil { if me.current == nil {
msg(w, "findNext() == nil") log.Info("findNext() == nil")
return return
} }
msg(w, me.current.StandardHeader()) log.Info(me.current.StandardHeader())
msg(w, me.current.StandardReleaseHeader()) log.Info(me.current.StandardReleaseHeader())
case "/rescanAll": case "/rescanAll":
me.repos.View.ScanRepositories() me.repos.View.ScanRepositories()
case "/setCurrentRepo": case "/setCurrentRepo":
msg(w, "repo: "+repoName) log.Info("repo: "+repoName)
msg(w, "version: "+version) log.Info("version: "+version)
msg(w, "comment: "+comment) log.Info("comment: "+comment)
repo := me.repos.View.FindRepoByName(repoName) repo := me.repos.View.FindRepoByName(repoName)
if repo == nil { if repo == nil {
msg(w, "FindRepoByName() returned nil") log.Info("FindRepoByName() returned nil")
return return
} }
setCurrentRepo(repo, "HTTP", "doRelease() ?") setCurrentRepo(repo, "HTTP", "doRelease() ?")
case "/IncrementRevisonVersion": case "/IncrementRevisonVersion":
msg(w, "repo: "+repoName) log.Info("repo: "+repoName)
msg(w, "version: "+version) log.Info("version: "+version)
me.current.Status.IncrementRevisionVersion(comment) me.current.Status.IncrementRevisionVersion(comment)
case "/IncrementMinorVersion": case "/IncrementMinorVersion":
msg(w, "repo: "+repoName) log.Info("repo: "+repoName)
msg(w, "version: "+version) log.Info("version: "+version)
me.current.Status.IncrementMinorVersion("trying minor") me.current.Status.IncrementMinorVersion("trying minor")
case "/setAllBranchesToMaster": case "/setAllBranchesToMaster":
msg(w, "set all branches to master") log.Info("set all branches to master")
me.Disable() me.Disable()
defer me.Enable() defer me.Enable()
if setAllBranchesToMaster() { if setAllBranchesToMaster() {
@ -127,15 +127,15 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
} }
return return
case "/setTargetVersion": case "/setTargetVersion":
msg(w, "repo: "+repoName) log.Info("repo: "+repoName)
msg(w, "version: "+version) log.Info("version: "+version)
if me.current == nil { if me.current == nil {
msg(w, "me.current == nil") log.Info("me.current == nil")
return return
} }
me.current.Status.SetTargetVersion(version) me.current.Status.SetTargetVersion(version)
case "/setAllTargetVersions": case "/setAllTargetVersions":
msg(w, "version: "+version) log.Info("version: "+version)
loop := me.repos.View.ReposSortByName() loop := me.repos.View.ReposSortByName()
for loop.Scan() { for loop.Scan() {
@ -152,77 +152,77 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
case "/whitelist": case "/whitelist":
repo := me.repos.View.FindRepoByName(repoName) repo := me.repos.View.FindRepoByName(repoName)
if repo == nil { if repo == nil {
msg(w, "FindRepoByName() returned nil") log.Info("FindRepoByName() returned nil")
return return
} }
msg(w, "whitelisted "+repo.Name()) log.Info("whitelisted "+repo.Name())
if whitelist == "false" { if whitelist == "false" {
repo.Status.Whitelist = false repo.Status.Whitelist = false
} else { } else {
repo.Status.Whitelist = true repo.Status.Whitelist = true
} }
case "/showNext": case "/showNext":
msg(w, "gui repo: "+me.release.repo.String()) log.Info("gui repo: "+me.release.repo.String())
msg(w, "gui name: "+me.release.version.String()) log.Info("gui name: "+me.release.version.String())
msg(w, "gui notes: "+me.release.notes.String()) log.Info("gui notes: "+me.release.notes.String())
msg(w, "gui status: "+me.release.status.String()) log.Info("gui status: "+me.release.status.String())
msg(w, "") log.Info("")
if me.current == nil { if me.current == nil {
msg(w, "me.current == nil") log.Info("me.current == nil")
return return
} }
if checkValidGoSum(me.current) { if checkValidGoSum(me.current) {
msg(w, "checkValidGoSum() == true") log.Info("checkValidGoSum() == true")
} else { } else {
msg(w, "checkValidGoSum() == false SHOULD NOT RELEASE THIS") log.Info("checkValidGoSum() == false SHOULD NOT RELEASE THIS")
} }
if me.current.Status.IsReleased() { if me.current.Status.IsReleased() {
msg(w, "IsReleased() == true SHOULD NOT RELEASE THIS") log.Info("IsReleased() == true SHOULD NOT RELEASE THIS")
} else { } else {
msg(w, "IsReleased() == false") log.Info("IsReleased() == false")
} }
if me.current.Status.CheckDirty() { if me.current.Status.CheckDirty() {
msg(w, "CheckDirty() == true. SHOULD NOT RELEASE THIS") log.Info("CheckDirty() == true. SHOULD NOT RELEASE THIS")
} else { } else {
msg(w, "CheckDirty() == false") log.Info("CheckDirty() == false")
} }
if me.current.Status.IsPrimitive() { if me.current.Status.IsPrimitive() {
msg(w, "IsPrimitive() == true") log.Info("IsPrimitive() == true")
} else { } else {
msg(w, "IsPrimitive() == false") log.Info("IsPrimitive() == false")
} }
if ok, compiled, err := me.current.Status.IsProtobuf(); ok { if ok, compiled, err := me.current.Status.IsProtobuf(); ok {
msg(w, log.Sprint("IsProtobuf() == true compiled protobuf files = ", compiled)) log.Info(log.Sprint("IsProtobuf() == true compiled protobuf files = ", compiled))
if err != nil { if err != nil {
msg(w, log.Sprint("IsProtobuf() == err", err)) log.Info(log.Sprint("IsProtobuf() == err", err))
os.Exit(-1) os.Exit(-1)
} }
for _, s := range compiled { for _, s := range compiled {
log.Info("\tcompiled file found:", s) log.Info("\tcompiled file found:", s)
} }
} else { } else {
msg(w, "IsProtobuf() == false") log.Info("IsProtobuf() == false")
msg(w, log.Sprint("IsProtobuf() == err", err)) log.Info(log.Sprint("IsProtobuf() == err", err))
} }
if me.current.Status.Whitelist { if me.current.Status.Whitelist {
msg(w, "Whitelist == true SHOULD NOT RELEASE THIS") log.Info("Whitelist == true SHOULD NOT RELEASE THIS")
} else { } else {
msg(w, "Whitelist == false") log.Info("Whitelist == false")
} }
msg(w, "") log.Info("")
msg(w, repolist.ReportHeader()) log.Info(repolist.ReportHeader())
msg(w, me.current.StandardHeader()) log.Info(me.current.StandardHeader())
msg(w, "") log.Info("")
msg(w, repolist.ReleaseReportHeader()) log.Info(repolist.ReleaseReportHeader())
msg(w, me.current.StandardReleaseHeader()) log.Info(me.current.StandardReleaseHeader())
case "/list": case "/list":
me.repos.View.PrintReport(w, readonly, onlydirty, perfect) me.repos.View.PrintReport(w, readonly, onlydirty, perfect)
case "/releaseList": case "/releaseList":
me.repos.View.PrintReleaseReport(w, readonly, perfect) me.repos.View.PrintReleaseReport(w, readonly, perfect)
case "/quit": case "/quit":
msg(w, "Got URL /quit") log.Info("Got URL /quit")
os.Exit(0) os.Exit(0)
case "/goweblist": case "/goweblist":
loop := me.repos.View.ReposAll() loop := me.repos.View.ReposAll()
@ -233,7 +233,7 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
tag := repo.Status.NewestTag() tag := repo.Status.NewestTag()
gitAge, err := tag.GetDate() gitAge, err := tag.GetDate()
if err != nil { if err != nil {
msg(w, fmt.Sprintf("tag date error", repo.Name())) log.Info(fmt.Sprintf("tag date error", repo.Name()))
} }
// if lastTag == "" { // if lastTag == "" {
// lastTag = tag.Name() // lastTag = tag.Name()
@ -244,17 +244,17 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
} }
} }
// dur := time.Since(gitAge) // dur := time.Since(gitAge)
// msg(w, fmt.Sprintf("%-60s %s %s %s", repo.Name(), lastTag, shell.FormatDuration(dur), lastTag, tag.Name())) // log.Info(fmt.Sprintf("%-60s %s %s %s", repo.Name(), lastTag, shell.FormatDuration(dur), lastTag, tag.Name()))
msg(w, fmt.Sprintf("%s %d %s", repo.Name(), gitAge.Unix(), lastTag)) log.Info(fmt.Sprintf("%s %d %s", repo.Name(), gitAge.Unix(), lastTag))
/* /*
for _, tag := range repo.Tags.ListAll() { for _, tag := range repo.Tags.ListAll() {
msg(w, fmt.Sprintf("%-60s %s", "", tag.Name())) log.Info(fmt.Sprintf("%-60s %s", "", tag.Name()))
} }
*/ */
} }
default: default:
msg(w, "BAD URL = "+route) log.Info("BAD URL = "+route)
} }
} }