whitelist is working
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
a3a1c09005
commit
c34090e798
|
@ -2,6 +2,9 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
|
@ -15,34 +18,65 @@ func CheckReady() bool {
|
|||
lastS := release.current.status.GetLastTagVersion()
|
||||
log.Info("repo:", release.current.String(), goSumS, dirtyS, lastS)
|
||||
|
||||
if dirtyS == "ready to tag version" {
|
||||
log.Info("\trepo is ready", release.current.String(), goSumS, dirtyS, lastS)
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
|
||||
if release.current.status.ReadOnly() {
|
||||
log.Info("\trepo is read only")
|
||||
return false
|
||||
}
|
||||
|
||||
if release.versionS == lastS {
|
||||
log.Info("\trepo is already done")
|
||||
log.Info("\trepo is already done", lastS, "=", release.versionS)
|
||||
return false
|
||||
}
|
||||
|
||||
if goSumS == "BAD" {
|
||||
log.Info("\trepo is ready", release.current.String(), goSumS, dirtyS, lastS)
|
||||
log.Info("\trepo is ready", release.current.String(), "BAD == BAD")
|
||||
} else {
|
||||
log.Info("\trepo is ready maybe", release.current.String(), goSumS, dirtyS, lastS)
|
||||
log.Info("\trepo is ready maybe", release.current.String(), "BAD !=", goSumS)
|
||||
}
|
||||
|
||||
if release.current.status.CheckDirty() {
|
||||
log.Info("\trepo is dirty")
|
||||
return false
|
||||
} else {
|
||||
log.Info("\trepo is ready", release.current.String(), goSumS, dirtyS, lastS)
|
||||
log.Info("\trepo is ready", release.current.String(), "not dirty")
|
||||
}
|
||||
|
||||
fullpath := filepath.Join(me.goSrcPwd.String(), release.current.String())
|
||||
|
||||
testf := filepath.Join(fullpath, "go.mod")
|
||||
if Exists(testf) {
|
||||
log.Info("\trepo is not ready. go.mod exists")
|
||||
return false
|
||||
}
|
||||
|
||||
testf = filepath.Join(fullpath, "go.sum")
|
||||
if Exists(testf) {
|
||||
log.Info("\trepo is not ready. go.sum exists")
|
||||
return false
|
||||
}
|
||||
|
||||
testf = filepath.Join(fullpath, "LICENSE")
|
||||
if ! Exists(testf) {
|
||||
log.Info("\trepo is not ready. missing LICENSE")
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
// final checks here
|
||||
if dirtyS == "ready to tag version" {
|
||||
log.Info("\trepo is ready", release.current.String(), "ready to tag version")
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// returns true if the file exists
|
||||
func Exists(file string) bool {
|
||||
_, err := os.Stat(file)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package main
|
|||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
|
@ -29,7 +30,7 @@ type releaseStruct struct {
|
|||
version *gadgets.OneLiner
|
||||
versionS string
|
||||
reason *gadgets.BasicEntry
|
||||
reasonS string
|
||||
reasonS string
|
||||
|
||||
openrepo *gui.Node
|
||||
|
||||
|
@ -39,6 +40,7 @@ type releaseStruct struct {
|
|||
makeRedomodB *gui.Node
|
||||
sendVersionB *gui.Node
|
||||
checkSafeB *gui.Node
|
||||
whitelist map[string]*repo
|
||||
}
|
||||
|
||||
func (w *autoType) Disable() {
|
||||
|
@ -49,11 +51,27 @@ func (w *autoType) Enable() {
|
|||
w.mainWindow.Enable()
|
||||
}
|
||||
|
||||
func whitelist(path string) bool {
|
||||
// log.Info("whitelist START", path)
|
||||
_, ok := release.whitelist[path]
|
||||
if ok {
|
||||
// log.Info("whitelist ok == true", path)
|
||||
return true
|
||||
}
|
||||
// log.Info("whitelist ok == false", path)
|
||||
return false
|
||||
}
|
||||
|
||||
func createReleaseBox(box *gui.Node) {
|
||||
release.versionS = "0.17.0"
|
||||
release.reasonS = "gocui"
|
||||
partS := strings.Split(release.versionS, ".")
|
||||
|
||||
release.whitelist = make(map[string]*repo)
|
||||
|
||||
release.whitelist["go.wit.com/apps/guireleaser"] = nil
|
||||
release.whitelist["go.wit.com/lib/gui/repostatus"] = nil
|
||||
|
||||
release.box = box
|
||||
release.group = release.box.NewGroup("things")
|
||||
release.grid = release.group.NewGrid("buildOptions", 2, 1)
|
||||
|
@ -61,13 +79,9 @@ func createReleaseBox(box *gui.Node) {
|
|||
// do an initial scan of all the repos
|
||||
scanGoSum()
|
||||
|
||||
release.grid.NewButton("findNextBad()", func() {
|
||||
release.grid.NewButton("scan for Ready", func() {
|
||||
me.Disable()
|
||||
if findNextBad() {
|
||||
log.Info("findNextBad() found a repo")
|
||||
me.Enable()
|
||||
return
|
||||
}
|
||||
scanForReady()
|
||||
me.Enable()
|
||||
})
|
||||
release.grid.NewButton("findNextDirty()", func() {
|
||||
|
@ -79,17 +93,6 @@ func createReleaseBox(box *gui.Node) {
|
|||
}
|
||||
me.Enable()
|
||||
})
|
||||
release.grid.NewButton("Check Ready", func() {
|
||||
goSumS := release.current.getGoSumStatus()
|
||||
dirtyS := release.current.dirtyLabel.String()
|
||||
lastS := release.current.status.GetLastTagVersion()
|
||||
if CheckReady() {
|
||||
log.Info("repo is ready", release.current.String(), goSumS, dirtyS, lastS)
|
||||
return
|
||||
} else {
|
||||
log.Info("\trepo is not ready", release.current.String(), goSumS, dirtyS, lastS)
|
||||
}
|
||||
})
|
||||
release.grid.NewButton("next repo", func() {
|
||||
buttonDisable()
|
||||
defer buttonEnable()
|
||||
|
@ -186,15 +189,43 @@ func createReleaseBox(box *gui.Node) {
|
|||
release.reason = gadgets.NewBasicEntry(release.grid, "release reason")
|
||||
release.reason.SetText(release.reasonS)
|
||||
|
||||
me.autoWorkingPwd = gadgets.NewOneLiner(release.grid, "working directory (pwd)")
|
||||
me.userHomePwd = gadgets.NewOneLiner(release.grid, "user home")
|
||||
me.goSrcPwd = gadgets.NewOneLiner(release.grid, "go src home")
|
||||
|
||||
homeDir, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
log.Warn("Error getting home directory:", err)
|
||||
homeDir = "/home/autotypist"
|
||||
}
|
||||
me.userHomePwd.SetText(homeDir)
|
||||
srcDir := filepath.Join(homeDir, "go/src")
|
||||
me.goSrcPwd.SetText(srcDir)
|
||||
|
||||
release.grid.NewButton("Check Ready", func() {
|
||||
goSumS := release.current.getGoSumStatus()
|
||||
dirtyS := release.current.dirtyLabel.String()
|
||||
lastS := release.current.status.GetLastTagVersion()
|
||||
if CheckReady() {
|
||||
log.Info("repo is ready", release.current.String(), goSumS, dirtyS, lastS)
|
||||
return
|
||||
} else {
|
||||
log.Info("\trepo is not ready", release.current.String(), goSumS, dirtyS, lastS)
|
||||
}
|
||||
})
|
||||
|
||||
release.sendVersionB = release.grid.NewButton("send version", func() {
|
||||
log.Info("set version()")
|
||||
release.current.status.SetVersion(partS[0], partS[1], partS[2], release.reason.String())
|
||||
})
|
||||
|
||||
release.grid.NewButton("set ignore", func() {
|
||||
tmp := release.current.getGoSumStatus()
|
||||
log.Info("trying to set repo IGNORE is now =", tmp)
|
||||
release.current.setGoSumStatus("IGNORE")
|
||||
release.whitelist[release.current.String()] = release.current
|
||||
})
|
||||
|
||||
release.checkDirtyB = release.grid.NewButton("checkDirty()", func() {
|
||||
buttonDisable()
|
||||
if release.current.checkDirty() {
|
||||
|
@ -204,6 +235,7 @@ func createReleaseBox(box *gui.Node) {
|
|||
}
|
||||
buttonEnable()
|
||||
})
|
||||
|
||||
release.checkSafeB = release.grid.NewButton("checkSafeGoSumRemake()", func() {
|
||||
buttonDisable()
|
||||
release.current.checkSafeGoSumRemake()
|
||||
|
@ -331,27 +363,37 @@ func setCurrentRepo(newcur *repo, s string, note string) bool {
|
|||
release.current = newcur
|
||||
release.openrepo.Enable()
|
||||
|
||||
/*
|
||||
if newcur.status.ReadOnly() {
|
||||
release.readOnly.SetValue("true ro")
|
||||
} else {
|
||||
release.readOnly.SetValue("false ro")
|
||||
}
|
||||
*/
|
||||
return true
|
||||
}
|
||||
|
||||
func findNextBad() bool {
|
||||
func scanForReady() bool {
|
||||
for _, repo := range me.allrepos {
|
||||
goSumS := repo.getGoSumStatus()
|
||||
dirtyS := repo.dirtyLabel.String()
|
||||
|
||||
log.Info("findNextDirty()", repo.String(), goSumS, dirtyS)
|
||||
if goSumS == "BAD" {
|
||||
if setCurrentRepo(repo, "primative not committed", "release new version") {
|
||||
return true
|
||||
if whitelist(repo.String()) {
|
||||
log.Info("found WHITELIST", repo.String())
|
||||
repo.setGoSumStatus("WHITELIST")
|
||||
continue
|
||||
}
|
||||
|
||||
log.Info("scan for Ready: found a repo")
|
||||
if setCurrentRepo(repo, "checking ready", "notsure") {
|
||||
if CheckReady() {
|
||||
release.current.setGoSumStatus("READY")
|
||||
} else {
|
||||
release.current.setGoSumStatus("NOT READY")
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
return true
|
||||
}
|
||||
|
||||
func findNextDirty() bool {
|
||||
|
|
10
repolist.go
10
repolist.go
|
@ -177,20 +177,14 @@ func addRepo(grid *gui.Node, path string, master string, devel string, user stri
|
|||
}
|
||||
log.Warn("status window exists. trying TestDraw() here")
|
||||
newRepo.status.Toggle()
|
||||
/// newRepo.status.Update()
|
||||
setCurrentRepo(newRepo, "manually chosen", "notsure")
|
||||
// newRepo.status.Update()
|
||||
})
|
||||
|
||||
// newRepo.status = repostatus.New(me.myGui, newRepo.path)
|
||||
newRepo.status = repostatus.NewRepoStatusWindow(newRepo.path)
|
||||
newRepo.hidden = false
|
||||
newRepo.status.SetMainWorkingName(master)
|
||||
newRepo.status.SetDevelWorkingName(devel)
|
||||
newRepo.status.SetUserWorkingName(user)
|
||||
/*
|
||||
newRepo.status.SetDevelBranchName(devel)
|
||||
newRepo.status.SetUserBranchName(user)
|
||||
newRepo.status.Update()
|
||||
newRepo.newScan()
|
||||
*/
|
||||
me.allrepos[path] = newRepo
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue