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
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -15,34 +18,65 @@ func CheckReady() bool {
|
||||||
lastS := release.current.status.GetLastTagVersion()
|
lastS := release.current.status.GetLastTagVersion()
|
||||||
log.Info("repo:", release.current.String(), goSumS, dirtyS, lastS)
|
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() {
|
if release.current.status.ReadOnly() {
|
||||||
log.Info("\trepo is read only")
|
log.Info("\trepo is read only")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if release.versionS == lastS {
|
if release.versionS == lastS {
|
||||||
log.Info("\trepo is already done")
|
log.Info("\trepo is already done", lastS, "=", release.versionS)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if goSumS == "BAD" {
|
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 {
|
} 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() {
|
if release.current.status.CheckDirty() {
|
||||||
log.Info("\trepo is dirty")
|
log.Info("\trepo is dirty")
|
||||||
return false
|
return false
|
||||||
} else {
|
} 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
|
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 (
|
import (
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
@ -39,6 +40,7 @@ type releaseStruct struct {
|
||||||
makeRedomodB *gui.Node
|
makeRedomodB *gui.Node
|
||||||
sendVersionB *gui.Node
|
sendVersionB *gui.Node
|
||||||
checkSafeB *gui.Node
|
checkSafeB *gui.Node
|
||||||
|
whitelist map[string]*repo
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *autoType) Disable() {
|
func (w *autoType) Disable() {
|
||||||
|
@ -49,11 +51,27 @@ func (w *autoType) Enable() {
|
||||||
w.mainWindow.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) {
|
func createReleaseBox(box *gui.Node) {
|
||||||
release.versionS = "0.17.0"
|
release.versionS = "0.17.0"
|
||||||
release.reasonS = "gocui"
|
release.reasonS = "gocui"
|
||||||
partS := strings.Split(release.versionS, ".")
|
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.box = box
|
||||||
release.group = release.box.NewGroup("things")
|
release.group = release.box.NewGroup("things")
|
||||||
release.grid = release.group.NewGrid("buildOptions", 2, 1)
|
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
|
// do an initial scan of all the repos
|
||||||
scanGoSum()
|
scanGoSum()
|
||||||
|
|
||||||
release.grid.NewButton("findNextBad()", func() {
|
release.grid.NewButton("scan for Ready", func() {
|
||||||
me.Disable()
|
me.Disable()
|
||||||
if findNextBad() {
|
scanForReady()
|
||||||
log.Info("findNextBad() found a repo")
|
|
||||||
me.Enable()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
me.Enable()
|
me.Enable()
|
||||||
})
|
})
|
||||||
release.grid.NewButton("findNextDirty()", func() {
|
release.grid.NewButton("findNextDirty()", func() {
|
||||||
|
@ -79,17 +93,6 @@ func createReleaseBox(box *gui.Node) {
|
||||||
}
|
}
|
||||||
me.Enable()
|
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() {
|
release.grid.NewButton("next repo", func() {
|
||||||
buttonDisable()
|
buttonDisable()
|
||||||
defer buttonEnable()
|
defer buttonEnable()
|
||||||
|
@ -186,15 +189,43 @@ func createReleaseBox(box *gui.Node) {
|
||||||
release.reason = gadgets.NewBasicEntry(release.grid, "release reason")
|
release.reason = gadgets.NewBasicEntry(release.grid, "release reason")
|
||||||
release.reason.SetText(release.reasonS)
|
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() {
|
release.sendVersionB = release.grid.NewButton("send version", func() {
|
||||||
log.Info("set version()")
|
log.Info("set version()")
|
||||||
release.current.status.SetVersion(partS[0], partS[1], partS[2], release.reason.String())
|
release.current.status.SetVersion(partS[0], partS[1], partS[2], release.reason.String())
|
||||||
})
|
})
|
||||||
|
|
||||||
release.grid.NewButton("set ignore", func() {
|
release.grid.NewButton("set ignore", func() {
|
||||||
tmp := release.current.getGoSumStatus()
|
tmp := release.current.getGoSumStatus()
|
||||||
log.Info("trying to set repo IGNORE is now =", tmp)
|
log.Info("trying to set repo IGNORE is now =", tmp)
|
||||||
release.current.setGoSumStatus("IGNORE")
|
release.current.setGoSumStatus("IGNORE")
|
||||||
|
release.whitelist[release.current.String()] = release.current
|
||||||
})
|
})
|
||||||
|
|
||||||
release.checkDirtyB = release.grid.NewButton("checkDirty()", func() {
|
release.checkDirtyB = release.grid.NewButton("checkDirty()", func() {
|
||||||
buttonDisable()
|
buttonDisable()
|
||||||
if release.current.checkDirty() {
|
if release.current.checkDirty() {
|
||||||
|
@ -204,6 +235,7 @@ func createReleaseBox(box *gui.Node) {
|
||||||
}
|
}
|
||||||
buttonEnable()
|
buttonEnable()
|
||||||
})
|
})
|
||||||
|
|
||||||
release.checkSafeB = release.grid.NewButton("checkSafeGoSumRemake()", func() {
|
release.checkSafeB = release.grid.NewButton("checkSafeGoSumRemake()", func() {
|
||||||
buttonDisable()
|
buttonDisable()
|
||||||
release.current.checkSafeGoSumRemake()
|
release.current.checkSafeGoSumRemake()
|
||||||
|
@ -331,27 +363,37 @@ func setCurrentRepo(newcur *repo, s string, note string) bool {
|
||||||
release.current = newcur
|
release.current = newcur
|
||||||
release.openrepo.Enable()
|
release.openrepo.Enable()
|
||||||
|
|
||||||
|
/*
|
||||||
if newcur.status.ReadOnly() {
|
if newcur.status.ReadOnly() {
|
||||||
release.readOnly.SetValue("true ro")
|
release.readOnly.SetValue("true ro")
|
||||||
} else {
|
} else {
|
||||||
release.readOnly.SetValue("false ro")
|
release.readOnly.SetValue("false ro")
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func findNextBad() bool {
|
func scanForReady() bool {
|
||||||
for _, repo := range me.allrepos {
|
for _, repo := range me.allrepos {
|
||||||
goSumS := repo.getGoSumStatus()
|
goSumS := repo.getGoSumStatus()
|
||||||
dirtyS := repo.dirtyLabel.String()
|
dirtyS := repo.dirtyLabel.String()
|
||||||
|
|
||||||
log.Info("findNextDirty()", repo.String(), goSumS, dirtyS)
|
log.Info("findNextDirty()", repo.String(), goSumS, dirtyS)
|
||||||
if goSumS == "BAD" {
|
if whitelist(repo.String()) {
|
||||||
if setCurrentRepo(repo, "primative not committed", "release new version") {
|
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 true
|
return true
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func findNextDirty() bool {
|
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")
|
log.Warn("status window exists. trying TestDraw() here")
|
||||||
newRepo.status.Toggle()
|
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.status = repostatus.NewRepoStatusWindow(newRepo.path)
|
||||||
newRepo.hidden = false
|
newRepo.hidden = false
|
||||||
newRepo.status.SetMainWorkingName(master)
|
newRepo.status.SetMainWorkingName(master)
|
||||||
newRepo.status.SetDevelWorkingName(devel)
|
newRepo.status.SetDevelWorkingName(devel)
|
||||||
newRepo.status.SetUserWorkingName(user)
|
newRepo.status.SetUserWorkingName(user)
|
||||||
/*
|
|
||||||
newRepo.status.SetDevelBranchName(devel)
|
|
||||||
newRepo.status.SetUserBranchName(user)
|
|
||||||
newRepo.status.Update()
|
|
||||||
newRepo.newScan()
|
|
||||||
*/
|
|
||||||
me.allrepos[path] = newRepo
|
me.allrepos[path] = newRepo
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue