using ENV for some settings
This commit is contained in:
parent
4501e1e381
commit
6286dd12e3
|
@ -10,51 +10,8 @@ import (
|
|||
"go.wit.com/gui"
|
||||
"go.wit.com/lib/gadgets"
|
||||
"go.wit.com/lib/gui/repolist"
|
||||
"go.wit.com/lib/gui/repostatus"
|
||||
)
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
func globalBuildOptions(vbox *gui.Node) {
|
||||
group1 := vbox.NewGroup("Global Build Options")
|
||||
grid := group1.NewGrid("buildOptions", 0, 0)
|
||||
|
@ -80,10 +37,17 @@ func globalBuildOptions(vbox *gui.Node) {
|
|||
// checking this will automatically make the branches off of devel
|
||||
grid.NextRow()
|
||||
me.autoCreateBranches = grid.NewCheckbox("create if missing").SetChecked(true)
|
||||
me.autoCreateBranches.Custom = func() {
|
||||
if me.autoCreateBranches.Checked() {
|
||||
os.Setenv("AUTOTYPIST_CREATE_BRANCHES", "on")
|
||||
} else {
|
||||
os.Unsetenv("AUTOTYPIST_CREATE_BRANCHES")
|
||||
}
|
||||
}
|
||||
grid.NextRow()
|
||||
|
||||
grid.NewButton("git checkout default", func() {
|
||||
me.repos.View.ArgCheckoutUser()
|
||||
me.repos.View.ArgCheckoutMaster()
|
||||
})
|
||||
grid.NewLabel("master,main,etc.") // set the order of these in the config file
|
||||
grid.NextRow()
|
||||
|
@ -99,13 +63,31 @@ func globalBuildOptions(vbox *gui.Node) {
|
|||
})
|
||||
grid.NewLabel(usr.Username)
|
||||
grid.NextRow()
|
||||
// select the branch you want to test, build and develop against
|
||||
|
||||
// select the branches you want to test, build and develop against
|
||||
// let's call this the 'mode' ?
|
||||
// this lets you select your user branch, but, when you are happy
|
||||
// you can merge everything into the devel branch and make sure it actually
|
||||
// works. Then, when that is good, merge and version everything in master
|
||||
me.setBranchB = grid.NewButton("set current branch to:", func() {
|
||||
targetName := me.newBranch.String()
|
||||
log.Warn("setting all branches to", targetName)
|
||||
grid.NewButton("set working mode:", func() {
|
||||
me.Disable()
|
||||
targetMode := me.newMode.String()
|
||||
log.Warn("setting all branches to", targetMode)
|
||||
if me.autoCreateBranches.Checked() {
|
||||
os.Setenv("AUTOTYPIST_CREATE_BRANCHES", "on")
|
||||
} else {
|
||||
os.Unsetenv("AUTOTYPIST_CREATE_BRANCHES")
|
||||
}
|
||||
switch me.newMode.String() {
|
||||
case "master":
|
||||
me.repos.View.ArgCheckoutMaster()
|
||||
case "devel":
|
||||
me.repos.View.ArgCheckoutDevel()
|
||||
case "user":
|
||||
me.repos.View.ArgCheckoutUser()
|
||||
}
|
||||
me.Enable()
|
||||
/*
|
||||
var count int
|
||||
for _, repo := range repolist.AllRepos() {
|
||||
if repo.ReadOnly() {
|
||||
|
@ -141,16 +123,16 @@ func globalBuildOptions(vbox *gui.Node) {
|
|||
repo.Scan()
|
||||
count += 1
|
||||
}
|
||||
log.Info("set", count, "branches to", targetName)
|
||||
*/
|
||||
})
|
||||
me.newBranch = grid.NewDropdown()
|
||||
me.newBranch.AddText("master")
|
||||
me.newBranch.AddText("devel")
|
||||
me.newBranch.AddText(usr.Username)
|
||||
me.newBranch.SetText(usr.Username)
|
||||
me.newMode = grid.NewDropdown()
|
||||
me.newMode.AddText("git default")
|
||||
me.newMode.AddText("devel")
|
||||
me.newMode.AddText("user")
|
||||
me.newMode.SetText("user")
|
||||
|
||||
grid.NextRow()
|
||||
me.setBranchB = grid.NewButton("git fetch master & devel", func() {
|
||||
grid.NewButton("git fetch master & devel", func() {
|
||||
me.Disable()
|
||||
defer me.Enable()
|
||||
log.Warn("updating all master branches")
|
||||
|
|
|
@ -1,48 +1,15 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"go.wit.com/gui"
|
||||
"go.wit.com/lib/debugger"
|
||||
"go.wit.com/lib/gui/gowit"
|
||||
"go.wit.com/lib/gui/logsettings"
|
||||
"go.wit.com/lib/gui/repolist"
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
func hideFunction(r *repolist.RepoRow) {
|
||||
if r.Status.IsDirty() {
|
||||
r.Show()
|
||||
return
|
||||
}
|
||||
if me.autoHideReadOnly.Checked() {
|
||||
if r.Status.ReadOnly() {
|
||||
r.Hide()
|
||||
return
|
||||
}
|
||||
}
|
||||
if me.autoHidePerfect.Checked() {
|
||||
if r.IsPerfect() {
|
||||
r.Hide()
|
||||
return
|
||||
}
|
||||
}
|
||||
r.Show()
|
||||
}
|
||||
|
||||
func hideFunction2(repo *repolist.RepoRow) {
|
||||
if me.autoHideReadOnly.Checked() {
|
||||
if repo.Status.ReadOnly() {
|
||||
return
|
||||
}
|
||||
}
|
||||
if me.autoHidePerfect.Checked() {
|
||||
if repo.IsPerfect() {
|
||||
return
|
||||
}
|
||||
}
|
||||
repo.Show()
|
||||
}
|
||||
|
||||
func globalDisplayOptions(vbox *gui.Node) {
|
||||
group1 := vbox.NewGroup("Global Display Options")
|
||||
|
||||
|
@ -57,20 +24,31 @@ func globalDisplayOptions(vbox *gui.Node) {
|
|||
|
||||
me.autoHideReadOnly = group1.NewCheckbox("Hide read-only repos").SetChecked(true)
|
||||
me.autoHideReadOnly.Custom = func() {
|
||||
me.repos.View.RegisterHideFunction(hideFunction)
|
||||
me.repos.View.ScanRepositories()
|
||||
if me.autoHideReadOnly.Checked() {
|
||||
os.Setenv("AUTOTYPIST_READONLY", "hide")
|
||||
} else {
|
||||
os.Unsetenv("AUTOTYPIST_READONLY")
|
||||
}
|
||||
}
|
||||
|
||||
me.autoHidePerfect = group1.NewCheckbox("Hide Perfectly clean repos").SetChecked(true)
|
||||
me.autoHidePerfect.Custom = func() {
|
||||
me.repos.View.RegisterHideFunction(hideFunction)
|
||||
me.repos.View.ScanRepositories()
|
||||
if me.autoHideReadOnly.Checked() {
|
||||
os.Setenv("AUTOTYPIST_CLEAN", "hide")
|
||||
} else {
|
||||
os.Unsetenv("AUTOTYPIST_CLEAN")
|
||||
}
|
||||
}
|
||||
scanbox := group1.Box().Horizontal()
|
||||
me.autoScanReposCB = scanbox.NewCheckbox("auto scan").SetChecked(true)
|
||||
me.autoScanReposCB.Custom = func() {
|
||||
me.repos.View.SetAutoScan(me.autoScanReposCB.Checked())
|
||||
if me.autoScanReposCB.Checked() {
|
||||
os.Setenv("REPO_AUTO_SCAN", "true")
|
||||
} else {
|
||||
os.Unsetenv("REPO_AUTO_SCAN")
|
||||
}
|
||||
}
|
||||
os.Setenv("REPO_AUTO_SCAN", "true")
|
||||
scanbox.NewButton("scan now", func() {
|
||||
log.Info("re-scanning repos now")
|
||||
i, s := me.repos.View.ScanRepositories()
|
||||
|
@ -111,15 +89,3 @@ func debuggerBox(vbox *gui.Node) {
|
|||
debugger.DebugWindow()
|
||||
})
|
||||
}
|
||||
|
||||
func hidePerfect() {
|
||||
for _, repo := range repolist.AllRepos() {
|
||||
if repo.IsPerfect() {
|
||||
if repo.Hidden() {
|
||||
continue
|
||||
}
|
||||
repo.Hide()
|
||||
// return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"go.wit.com/lib/gui/repolist"
|
||||
)
|
||||
|
||||
// like tcl/tk, use ENV variables to set display preferences
|
||||
func hideFunction(r *repolist.RepoRow) {
|
||||
// always show dirty repos
|
||||
if r.Status.IsDirty() {
|
||||
r.Show()
|
||||
return
|
||||
}
|
||||
|
||||
// hide read-only repos
|
||||
if os.Getenv("AUTOTYPIST_READONLY") == "hide" {
|
||||
if r.Status.ReadOnly() {
|
||||
r.Hide()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// show repos with mismatched mode
|
||||
// this means, if you are in "devel" mode, show all the repos that
|
||||
// might be stuck on the wrong branch, like 'master' or '<username>'
|
||||
if os.Getenv("AUTOTYPIST_MODE") != "" {
|
||||
if !r.Status.IsCorrectMode(os.Getenv("AUTOTYPIST_MODE")) {
|
||||
r.Show()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// hide perfectly clean repos
|
||||
if os.Getenv("AUTOTYPIST_CLEAN") == "hide" {
|
||||
if r.IsPerfect() {
|
||||
r.Hide()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// show everything else. often this will be "unconforming" repos
|
||||
// if you what those repos ignored, add these to the config file
|
||||
// as read-only=true
|
||||
r.Show()
|
||||
}
|
1
main.go
1
main.go
|
@ -52,7 +52,6 @@ func main() {
|
|||
|
||||
// setup the autoscan functions
|
||||
me.repos.View.RegisterHideFunction(hideFunction)
|
||||
me.repos.View.SetAutoScan(me.autoScanReposCB.Checked())
|
||||
|
||||
// processing is done. update the repo summary box
|
||||
// me.summary.Update()
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"go.wit.com/log"
|
||||
|
||||
"go.wit.com/lib/gui/repostatus"
|
||||
)
|
||||
|
||||
// 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
|
||||
}
|
|
@ -77,8 +77,7 @@ type autoType struct {
|
|||
// when switch to user or devel branches, autocreate them
|
||||
autoCreateBranches *gui.Node
|
||||
|
||||
// these hold the branches that the user can switch all
|
||||
// the repositories to them
|
||||
newBranch *gui.Node
|
||||
setBranchB *gui.Node
|
||||
// make a concept called a 'mode' that means which branches
|
||||
// are you working from: "master"? "devel"? <username>?
|
||||
newMode *gui.Node
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue