From e68cb3e80f792b0288680ec04ceb4b9c77426563 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Mon, 23 Dec 2024 03:27:29 -0600 Subject: button for repo window --- globalBuildOptions.go | 91 ------------------------------------------- globalDisplayOptions.go | 62 ------------------------------ subitPatches.go | 100 ++++++++++++++++++++++++++---------------------- window.go | 91 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 146 insertions(+), 198 deletions(-) delete mode 100644 globalBuildOptions.go delete mode 100644 globalDisplayOptions.go create mode 100644 window.go diff --git a/globalBuildOptions.go b/globalBuildOptions.go deleted file mode 100644 index 5f7a71b..0000000 --- a/globalBuildOptions.go +++ /dev/null @@ -1,91 +0,0 @@ -package main - -import ( - "os" - "os/user" - "path/filepath" - - "go.wit.com/gui" - "go.wit.com/lib/gadgets" - "go.wit.com/lib/gui/shell" - "go.wit.com/log" -) - -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 { - if me.autoDryRun.Checked() { - log.Warn("RUN --dry-run", fullpath, cmd) - return false - } else { - log.Warn("RUN:", fullpath, cmd) - } - - result := shell.PathRun(fullpath, cmd) - if result.Error != nil { - log.Warn("quickCmd() cmd =", cmd) - log.Warn("quickCmd() err =", result.Error) - log.Warn("quickCmd() b =", result.Exit) - log.Warn("quickCmd() output =", result.Stdout) - return false - } else if result.Exit != 0 { - log.Warn("quickCmd() b =", result.Exit) - log.Warn("quickCmd() output =", result.Stdout) - return true - } - log.Warn("quickCmd() output = ", result.Stdout) - return true -} - -func globalBuildOptions(vbox *gui.Node) { - group1 := vbox.NewGroup("Forge Settings") - grid := group1.NewGrid("buildOptions", 0, 0) - - // me.autoWorkingPwd = gadgets.NewOneLiner(grid, "working directory (pwd)") - me.userHomePwd = gadgets.NewOneLiner(grid, "user home") - grid.NextRow() - me.goSrcPwd = gadgets.NewOneLiner(grid, "go src home") - grid.NextRow() - - usr, _ := user.Current() - 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) - - // select the branch you want to test, build and develop against - // 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) - loop := me.repos.View.ReposSortByName() - for loop.Scan() { - repo := loop.Repo() - repo.Status.CheckoutBranch(targetName) - repo.Scan() - } - }) - me.newBranch = grid.NewCombobox() - me.newBranch.AddText("master") - me.newBranch.AddText("devel") - me.newBranch.AddText(usr.Username) - me.newBranch.SetText(usr.Username) - - // checking this will automatically make the branches off of devel - me.autoCreateBranches = grid.NewCheckbox("create if missing").SetChecked(true) - grid.NextRow() -} diff --git a/globalDisplayOptions.go b/globalDisplayOptions.go deleted file mode 100644 index 8d3db24..0000000 --- a/globalDisplayOptions.go +++ /dev/null @@ -1,62 +0,0 @@ -package main - -import ( - "go.wit.com/gui" - "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 globalDisplayOptions(vbox *gui.Node) { - group1 := vbox.NewGroup("Global Display Options") - - group1.NewButton("Show Repository Window", func() { - // globalDisplaySetRepoState() - if me.repos.Hidden() { - me.repos.Show() - } else { - me.repos.Hide() - } - }) - - me.autoHideReadOnly = group1.NewCheckbox("Hide read-only repos").SetChecked(true) - me.autoHideReadOnly.Custom = func() { - me.repos.View.RegisterHideFunction(hideFunction) - me.repos.View.ScanRepositories() - } - - me.autoHidePerfect = group1.NewCheckbox("Hide Perfectly clean repos").SetChecked(true) - me.autoHidePerfect.Custom = func() { - me.repos.View.RegisterHideFunction(hideFunction) - me.repos.View.ScanRepositories() - } - scanbox := group1.Box().Horizontal() - me.autoScanReposCB = scanbox.NewCheckbox("auto scan").SetChecked(true) - - scanbox.NewButton("scan now", func() { - log.Info("re-scanning repos now") - i, s := me.repos.View.ScanRepositories() - log.Info("re-scanning repos done", i, s) - }) -} diff --git a/subitPatches.go b/subitPatches.go index a653bcf..9929909 100644 --- a/subitPatches.go +++ b/subitPatches.go @@ -55,45 +55,44 @@ func submitPatchesBox(box *gui.Node) *patchSummary { group1 := box.NewGroup("Patch Summary") s.grid = group1.RawGrid() - s.grid.NewButton("Update Patch Counts", func() { - /* - var repocount, patchcount int - // broken after move to forge protobuf - all := me.forge.Repos.SortByFullPath() - for all.Scan() { - repo := all.Next() - if repo.GetReadOnly() { - continue - } - i, _ := repo.GetMasterPatches() - patchcount += i - if i > 0 { - repocount += 1 - } - } - s.totalMasterPatches.SetText(strconv.Itoa(patchcount) + " patches") - s.totalMasterRepos.SetText(strconv.Itoa(repocount) + " go repos") - - repocount = 0 - patchcount = 0 - // broken after move to forge protobuf - all = me.forge.Repos.SortByFullPath() - for all.Scan() { - repo := all.Next() - if repo.GetReadOnly() { - continue + /* + s.grid.NewButton("Update Patch Counts", func() { + var repocount, patchcount int + // broken after move to forge protobuf + all := me.forge.Repos.SortByFullPath() + for all.Scan() { + repo := all.Next() + if repo.GetReadOnly() { + continue + } + i, _ := repo.GetMasterPatches() + patchcount += i + if i > 0 { + repocount += 1 + } } - i, _ := repo.GetUserPatches() - patchcount += i - if i > 0 { - repocount += 1 + s.totalMasterPatches.SetText(strconv.Itoa(patchcount) + " patches") + s.totalMasterRepos.SetText(strconv.Itoa(repocount) + " go repos") + + repocount = 0 + patchcount = 0 + // broken after move to forge protobuf + all = me.forge.Repos.SortByFullPath() + for all.Scan() { + repo := all.Next() + if repo.GetReadOnly() { + continue + } + i, _ := repo.GetUserPatches() + patchcount += i + if i > 0 { + repocount += 1 + } } - } - s.totalUserPatches.SetText(strconv.Itoa(patchcount) + " patches") - s.totalUserRepos.SetText(strconv.Itoa(repocount) + " go repos") - */ - s.Update() - }) + s.totalUserPatches.SetText(strconv.Itoa(patchcount) + " patches") + s.totalUserRepos.SetText(strconv.Itoa(repocount) + " go repos") + }) + */ /* this used to be the way and should probably be revisited s.grid.NewButton("Make Patches", func() { @@ -138,14 +137,16 @@ func submitPatchesBox(box *gui.Node) *patchSummary { s.totalMasterPatches = s.grid.NewLabel("x patches") s.grid.NextRow() - s.grid.NewLabel("") - s.grid.NewLabel("") - s.grid.NewButton("merge from user", func() { - log.Info("this should make a patchset of your patches") - }) - s.grid.NewButton("merge from devel", func() { - log.Info("this probably should not exist") - }) + /* + s.grid.NewLabel("") + s.grid.NewLabel("") + s.grid.NewButton("merge from user", func() { + log.Info("this should make a patchset of your patches") + }) + s.grid.NewButton("merge from devel", func() { + log.Info("this probably should not exist") + }) + */ s.grid.NextRow() group1 = box.NewGroup("Submit Patch Set") @@ -172,6 +173,15 @@ func submitPatchesBox(box *gui.Node) *patchSummary { } me.repos.View.MakePatchset(patchdir) }) + s.grid.NewButton("Show Repos", func() { + s.Update() + if me.repos.Hidden() { + me.repos.Show() + } else { + me.repos.Hide() + } + }) + /* s.submitB = s.grid.NewButton("Submit quilt", func() { log.Info("do a submit here") diff --git a/window.go b/window.go new file mode 100644 index 0000000..5f7a71b --- /dev/null +++ b/window.go @@ -0,0 +1,91 @@ +package main + +import ( + "os" + "os/user" + "path/filepath" + + "go.wit.com/gui" + "go.wit.com/lib/gadgets" + "go.wit.com/lib/gui/shell" + "go.wit.com/log" +) + +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 { + if me.autoDryRun.Checked() { + log.Warn("RUN --dry-run", fullpath, cmd) + return false + } else { + log.Warn("RUN:", fullpath, cmd) + } + + result := shell.PathRun(fullpath, cmd) + if result.Error != nil { + log.Warn("quickCmd() cmd =", cmd) + log.Warn("quickCmd() err =", result.Error) + log.Warn("quickCmd() b =", result.Exit) + log.Warn("quickCmd() output =", result.Stdout) + return false + } else if result.Exit != 0 { + log.Warn("quickCmd() b =", result.Exit) + log.Warn("quickCmd() output =", result.Stdout) + return true + } + log.Warn("quickCmd() output = ", result.Stdout) + return true +} + +func globalBuildOptions(vbox *gui.Node) { + group1 := vbox.NewGroup("Forge Settings") + grid := group1.NewGrid("buildOptions", 0, 0) + + // me.autoWorkingPwd = gadgets.NewOneLiner(grid, "working directory (pwd)") + me.userHomePwd = gadgets.NewOneLiner(grid, "user home") + grid.NextRow() + me.goSrcPwd = gadgets.NewOneLiner(grid, "go src home") + grid.NextRow() + + usr, _ := user.Current() + 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) + + // select the branch you want to test, build and develop against + // 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) + loop := me.repos.View.ReposSortByName() + for loop.Scan() { + repo := loop.Repo() + repo.Status.CheckoutBranch(targetName) + repo.Scan() + } + }) + me.newBranch = grid.NewCombobox() + me.newBranch.AddText("master") + me.newBranch.AddText("devel") + me.newBranch.AddText(usr.Username) + me.newBranch.SetText(usr.Username) + + // checking this will automatically make the branches off of devel + me.autoCreateBranches = grid.NewCheckbox("create if missing").SetChecked(true) + grid.NextRow() +} -- cgit v1.2.3