diff options
| author | Jeff Carr <[email protected]> | 2024-02-26 21:46:34 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-02-26 21:46:34 -0600 |
| commit | e825cffc8a42aa932b7e80cbaa8e8e679446c671 (patch) | |
| tree | fa52aa32eda2753f2aaa6edf2d3e3b39073e12c1 /hideFunction.go | |
| parent | 2d2fc80754b25bdc5fc23bd39595c377b331d1be (diff) | |
move show/hide function to seperate file
Diffstat (limited to 'hideFunction.go')
| -rw-r--r-- | hideFunction.go | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/hideFunction.go b/hideFunction.go new file mode 100644 index 0000000..30bf485 --- /dev/null +++ b/hideFunction.go @@ -0,0 +1,89 @@ +package main + +import ( + "os" + + "go.wit.com/lib/gui/repolist" + "go.wit.com/log" +) + +// like tcl/tk, use ENV variables to set display preferences +func hideFunction(r *repolist.RepoRow) { + if r.GoPath() == "go.wit.com/dev/alexflint/arg" { + log.Info("found autoHideReleased() =", me.autoHideReleased.Checked()) + log.Info("found alexflint/arg IsReleased() =", r.Status.IsReleased()) + } + + // 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() { + // log.Info(r.Name(), "hiding read-only repo") + r.Hide() + return + } else { + // log.Info(r.Name(), "not hiding read-only repo") + } + } + + // 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() +} + +func showHideRepos(repo *repolist.RepoRow) { + if repo.GoPath() == "go.wit.com/dev/alexflint/arg" { + log.Info("found autoHideReleased() =", me.autoHideReleased.Checked()) + log.Info("found alexflint/arg IsReleased() =", repo.Status.IsReleased()) + } + // always show dirty repos + if repo.IsDirty() { + repo.Show() + return + } + // always show repos that have not been merged ? + if repo.GoState() == "merge to devel" { + repo.Show() + return + } + + // hide read-only repos. These are repos that do not + // match things in the users config file (.config/autotypist) + if me.autoHideReadOnly.Checked() { + if repo.Status.ReadOnly() { + repo.Hide() + return + } + } + if me.autoHideReleased.Checked() { + if repo.Status.IsReleased() { + repo.Hide() + return + } + } + repo.Show() +} |
