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/gui"
|
||||||
"go.wit.com/lib/gadgets"
|
"go.wit.com/lib/gadgets"
|
||||||
"go.wit.com/lib/gui/repolist"
|
"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) {
|
func globalBuildOptions(vbox *gui.Node) {
|
||||||
group1 := vbox.NewGroup("Global Build Options")
|
group1 := vbox.NewGroup("Global Build Options")
|
||||||
grid := group1.NewGrid("buildOptions", 0, 0)
|
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
|
// checking this will automatically make the branches off of devel
|
||||||
grid.NextRow()
|
grid.NextRow()
|
||||||
me.autoCreateBranches = grid.NewCheckbox("create if missing").SetChecked(true)
|
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.NextRow()
|
||||||
|
|
||||||
grid.NewButton("git checkout default", func() {
|
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.NewLabel("master,main,etc.") // set the order of these in the config file
|
||||||
grid.NextRow()
|
grid.NextRow()
|
||||||
|
@ -99,58 +63,76 @@ func globalBuildOptions(vbox *gui.Node) {
|
||||||
})
|
})
|
||||||
grid.NewLabel(usr.Username)
|
grid.NewLabel(usr.Username)
|
||||||
grid.NextRow()
|
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
|
// 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
|
// 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
|
// works. Then, when that is good, merge and version everything in master
|
||||||
me.setBranchB = grid.NewButton("set current branch to:", func() {
|
grid.NewButton("set working mode:", func() {
|
||||||
targetName := me.newBranch.String()
|
me.Disable()
|
||||||
log.Warn("setting all branches to", targetName)
|
targetMode := me.newMode.String()
|
||||||
var count int
|
log.Warn("setting all branches to", targetMode)
|
||||||
for _, repo := range repolist.AllRepos() {
|
if me.autoCreateBranches.Checked() {
|
||||||
if repo.ReadOnly() {
|
os.Setenv("AUTOTYPIST_CREATE_BRANCHES", "on")
|
||||||
continue
|
} else {
|
||||||
}
|
os.Unsetenv("AUTOTYPIST_CREATE_BRANCHES")
|
||||||
if targetName == repo.Status.GetCurrentBranchName() {
|
}
|
||||||
continue
|
switch me.newMode.String() {
|
||||||
}
|
case "master":
|
||||||
if repo.Status.BranchExists(targetName) {
|
me.repos.View.ArgCheckoutMaster()
|
||||||
ok := repo.Status.CheckoutBranch(targetName)
|
case "devel":
|
||||||
if ok {
|
me.repos.View.ArgCheckoutDevel()
|
||||||
// checkout went fine
|
case "user":
|
||||||
|
me.repos.View.ArgCheckoutUser()
|
||||||
|
}
|
||||||
|
me.Enable()
|
||||||
|
/*
|
||||||
|
var count int
|
||||||
|
for _, repo := range repolist.AllRepos() {
|
||||||
|
if repo.ReadOnly() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
log.Info("couldn't set", repo.Status.Path(), "branch to", targetName)
|
if targetName == repo.Status.GetCurrentBranchName() {
|
||||||
log.Info("but branch exists so something went wrong")
|
continue
|
||||||
continue
|
}
|
||||||
|
if repo.Status.BranchExists(targetName) {
|
||||||
|
ok := repo.Status.CheckoutBranch(targetName)
|
||||||
|
if ok {
|
||||||
|
// checkout went fine
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
log.Info("couldn't set", repo.Status.Path(), "branch to", targetName)
|
||||||
|
log.Info("but branch exists so something went wrong")
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if !me.autoCreateBranches.Checked() {
|
||||||
|
log.Info("not auto creating branch", targetName)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
// branch doesn't exist. make it
|
||||||
|
// todo: make this branch from 'devel' branch if it exists
|
||||||
|
log.Info("should make the", targetName, "branch here!")
|
||||||
|
if me.autoCreateBranches.Checked() {
|
||||||
|
log.Info("going to make the branch!")
|
||||||
|
repo.Status.RunCmd([]string{"git", "branch", targetName})
|
||||||
|
repo.Status.RunCmd([]string{"git", "checkout", targetName})
|
||||||
|
} else {
|
||||||
|
log.Info("not auto creating branch", targetName)
|
||||||
|
}
|
||||||
|
repo.Scan()
|
||||||
|
count += 1
|
||||||
}
|
}
|
||||||
if !me.autoCreateBranches.Checked() {
|
*/
|
||||||
log.Info("not auto creating branch", targetName)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
// branch doesn't exist. make it
|
|
||||||
// todo: make this branch from 'devel' branch if it exists
|
|
||||||
log.Info("should make the", targetName, "branch here!")
|
|
||||||
if me.autoCreateBranches.Checked() {
|
|
||||||
log.Info("going to make the branch!")
|
|
||||||
repo.Status.RunCmd([]string{"git", "branch", targetName})
|
|
||||||
repo.Status.RunCmd([]string{"git", "checkout", targetName})
|
|
||||||
} else {
|
|
||||||
log.Info("not auto creating branch", targetName)
|
|
||||||
}
|
|
||||||
repo.Scan()
|
|
||||||
count += 1
|
|
||||||
}
|
|
||||||
log.Info("set", count, "branches to", targetName)
|
|
||||||
})
|
})
|
||||||
me.newBranch = grid.NewDropdown()
|
me.newMode = grid.NewDropdown()
|
||||||
me.newBranch.AddText("master")
|
me.newMode.AddText("git default")
|
||||||
me.newBranch.AddText("devel")
|
me.newMode.AddText("devel")
|
||||||
me.newBranch.AddText(usr.Username)
|
me.newMode.AddText("user")
|
||||||
me.newBranch.SetText(usr.Username)
|
me.newMode.SetText("user")
|
||||||
|
|
||||||
grid.NextRow()
|
grid.NextRow()
|
||||||
me.setBranchB = grid.NewButton("git fetch master & devel", func() {
|
grid.NewButton("git fetch master & devel", func() {
|
||||||
me.Disable()
|
me.Disable()
|
||||||
defer me.Enable()
|
defer me.Enable()
|
||||||
log.Warn("updating all master branches")
|
log.Warn("updating all master branches")
|
||||||
|
|
|
@ -1,48 +1,15 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
|
|
||||||
"go.wit.com/gui"
|
"go.wit.com/gui"
|
||||||
"go.wit.com/lib/debugger"
|
"go.wit.com/lib/debugger"
|
||||||
"go.wit.com/lib/gui/gowit"
|
"go.wit.com/lib/gui/gowit"
|
||||||
"go.wit.com/lib/gui/logsettings"
|
"go.wit.com/lib/gui/logsettings"
|
||||||
"go.wit.com/lib/gui/repolist"
|
|
||||||
"go.wit.com/log"
|
"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) {
|
func globalDisplayOptions(vbox *gui.Node) {
|
||||||
group1 := vbox.NewGroup("Global Display Options")
|
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 = group1.NewCheckbox("Hide read-only repos").SetChecked(true)
|
||||||
me.autoHideReadOnly.Custom = func() {
|
me.autoHideReadOnly.Custom = func() {
|
||||||
me.repos.View.RegisterHideFunction(hideFunction)
|
if me.autoHideReadOnly.Checked() {
|
||||||
me.repos.View.ScanRepositories()
|
os.Setenv("AUTOTYPIST_READONLY", "hide")
|
||||||
|
} else {
|
||||||
|
os.Unsetenv("AUTOTYPIST_READONLY")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
me.autoHidePerfect = group1.NewCheckbox("Hide Perfectly clean repos").SetChecked(true)
|
me.autoHidePerfect = group1.NewCheckbox("Hide Perfectly clean repos").SetChecked(true)
|
||||||
me.autoHidePerfect.Custom = func() {
|
me.autoHidePerfect.Custom = func() {
|
||||||
me.repos.View.RegisterHideFunction(hideFunction)
|
if me.autoHideReadOnly.Checked() {
|
||||||
me.repos.View.ScanRepositories()
|
os.Setenv("AUTOTYPIST_CLEAN", "hide")
|
||||||
|
} else {
|
||||||
|
os.Unsetenv("AUTOTYPIST_CLEAN")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
scanbox := group1.Box().Horizontal()
|
scanbox := group1.Box().Horizontal()
|
||||||
me.autoScanReposCB = scanbox.NewCheckbox("auto scan").SetChecked(true)
|
me.autoScanReposCB = scanbox.NewCheckbox("auto scan").SetChecked(true)
|
||||||
me.autoScanReposCB.Custom = func() {
|
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() {
|
scanbox.NewButton("scan now", func() {
|
||||||
log.Info("re-scanning repos now")
|
log.Info("re-scanning repos now")
|
||||||
i, s := me.repos.View.ScanRepositories()
|
i, s := me.repos.View.ScanRepositories()
|
||||||
|
@ -111,15 +89,3 @@ func debuggerBox(vbox *gui.Node) {
|
||||||
debugger.DebugWindow()
|
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
|
// setup the autoscan functions
|
||||||
me.repos.View.RegisterHideFunction(hideFunction)
|
me.repos.View.RegisterHideFunction(hideFunction)
|
||||||
me.repos.View.SetAutoScan(me.autoScanReposCB.Checked())
|
|
||||||
|
|
||||||
// processing is done. update the repo summary box
|
// processing is done. update the repo summary box
|
||||||
// me.summary.Update()
|
// 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
|
// when switch to user or devel branches, autocreate them
|
||||||
autoCreateBranches *gui.Node
|
autoCreateBranches *gui.Node
|
||||||
|
|
||||||
// these hold the branches that the user can switch all
|
// make a concept called a 'mode' that means which branches
|
||||||
// the repositories to them
|
// are you working from: "master"? "devel"? <username>?
|
||||||
newBranch *gui.Node
|
newMode *gui.Node
|
||||||
setBranchB *gui.Node
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue