summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-01-29 16:18:32 -0600
committerJeff Carr <[email protected]>2025-01-29 16:18:32 -0600
commit2395a4466e9c08112372c480b30ac0823eeeb549 (patch)
treeae008b2eadf649efd3950307f3896af891f84c33
parent2b2de94eff3ec37566665a22804c58c1ce764665 (diff)
delete old code. start refactor to protobufv0.22.39v0.22.38v0.22.37
-rw-r--r--branchesBox.go39
-rw-r--r--git.go4
-rw-r--r--update.go35
-rw-r--r--windowBranches.go125
-rw-r--r--windowMain.go (renamed from new.go)24
-rw-r--r--windowRepo.go73
6 files changed, 229 insertions, 71 deletions
diff --git a/branchesBox.go b/branchesBox.go
index 332f4ad..8849fb0 100644
--- a/branchesBox.go
+++ b/branchesBox.go
@@ -25,23 +25,36 @@ func (rs *RepoStatus) makeBranchesBox(parent *gui.Node) {
rs.currentVersion = gadgets.NewOneLiner(newgrid, "current version") // `progname:"CURRENTVERSION"`
newgrid.NextRow()
- rs.switchBranchB = newgrid.NewButton("Switch Branch", func() { // `progname:"SWITCH"`
- })
+ /*
+ rs.switchBranchB = newgrid.NewButton("Switch Branch", func() { // `progname:"SWITCH"`
+ })
- rs.targetBranch = newgrid.NewDropdown() // `progname:"TARGET"`
- newgrid.NextRow()
+ rs.targetBranch = newgrid.NewDropdown() // `progname:"TARGET"`
+ newgrid.NextRow()
- rs.showBranchesButton = newgrid.NewButton("find user and devel", func() {
- log.Info("redo this")
- })
- newgrid.NextRow()
+ rs.showBranchesButton = newgrid.NewButton("find user and devel", func() {
+ log.Info("redo this")
+ })
+ newgrid.NextRow()
- rs.checkBranchesButton = newgrid.NewButton("CheckBranches()", func() {
- log.Info("redo this")
- })
- newgrid.NextRow()
+ rs.checkBranchesButton = newgrid.NewButton("CheckBranches()", func() {
+ log.Info("redo this")
+ })
+ newgrid.NextRow()
+
+ newgrid.NewButton("Revert master to devel", func() {
+ log.Info("redo this")
+ })
+ */
- newgrid.NewButton("Revert master to devel", func() {
+ var win *repoBranchesWindow
+ newgrid.NewButton("Branches Window", func() {
+ if win != nil {
+ win.Toggle()
+ return
+ }
log.Info("redo this")
+ win = MakeRepoBranchesWindow(rs.pb)
+ win.Show()
})
}
diff --git a/git.go b/git.go
index 060ad1e..4e0c394 100644
--- a/git.go
+++ b/git.go
@@ -1,13 +1,15 @@
package repostatus
-// remove this everything
+// most everything here needs to be deprecated now
func (rs *RepoStatus) Path() string {
return rs.realPath.String()
}
+/*
func (rs *RepoStatus) GitState() string {
return rs.gitState.String()
}
+*/
func (rs *RepoStatus) GetStatus() string {
return rs.gitState.String()
diff --git a/update.go b/update.go
index 8774635..56ddd8c 100644
--- a/update.go
+++ b/update.go
@@ -47,38 +47,3 @@ func (rs *RepoStatus) CheckGitState() string {
rs.gitState.SetText(state)
return state
}
-
-/*
-func (rs *RepoStatus) setState() {
- pb := rs.pb
- rs.changed = false
- if pb.CheckDirty() {
- log.Log(REPO, "CheckDirty() true")
- rs.gitState.SetText("dirty")
- return
- }
- if pb.GetUserVersion() != pb.GetDevelVersion() {
- rs.gitState.SetText("merge to devel")
- return
- }
- if pb.GetDevelVersion() != pb.GetMasterVersion() {
- rs.gitState.SetText("merge to main")
- return
- }
- if pb.GetLastTag() != pb.GetMasterVersion() {
- rs.gitState.SetText("unchanged")
- return
- }
-
- if pb.CheckBranches() {
- log.Log(REPO, "Branches are Perfect")
- rs.gitState.SetText("PERFECT")
- return
- }
- log.Log(REPO, "FIND THIS IN REPO STATUS Branches are not Perfect")
- log.Log(REPO, "FIND THIS IN REPO STATUS Branches are not Perfect")
- log.Log(REPO, "FIND THIS IN REPO STATUS Branches are not Perfect")
- log.Log(REPO, "FIND THIS IN REPO STATUS Branches are not Perfect")
- rs.gitState.SetText("unknown branches")
-}
-*/
diff --git a/windowBranches.go b/windowBranches.go
new file mode 100644
index 0000000..3aba4e8
--- /dev/null
+++ b/windowBranches.go
@@ -0,0 +1,125 @@
+package repostatus
+
+import (
+ "go.wit.com/lib/gadgets"
+ "go.wit.com/lib/protobuf/gitpb"
+ "go.wit.com/log"
+
+ "go.wit.com/gui"
+)
+
+type repoBranchesWindow struct {
+ repo *gitpb.Repo // the repo protobuf
+ win *gadgets.BasicWindow // the patches window
+ stack *gui.Node // the top box set as vertical
+ //shelf *gui.Node // the first box in the stack, set as horizontal
+ //grid *gui.Node // the list of available patches
+ //setgrid *gui.Node // the list of each patchset
+}
+
+// todo: autogenerate these or make them standared 'gui' package functions
+// make this an go interface somehow
+
+// is the window hidden right now?
+func (w *repoBranchesWindow) Hidden() bool {
+ return w.win.Hidden()
+}
+
+// switches between the window being visable or hidden on the desktop
+func (w *repoBranchesWindow) Toggle() {
+ if w.Hidden() {
+ w.Show()
+ } else {
+ w.Hide()
+ }
+}
+
+// hides the window completely
+func (w *repoBranchesWindow) Show() {
+ w.win.Show()
+}
+
+func (w *repoBranchesWindow) Hide() {
+ w.win.Hide()
+}
+
+// should be the first box/widget in the window
+// greys out the window to the user
+func (w *repoBranchesWindow) Disable() {
+ w.stack.Disable()
+}
+
+func (w *repoBranchesWindow) Enable() {
+ w.stack.Enable()
+}
+
+// you can only have one of these
+func MakeRepoBranchesWindow(repo *gitpb.Repo) *repoBranchesWindow {
+ pw := new(repoBranchesWindow)
+
+ // sync.Once()
+ pw.win = gadgets.RawBasicWindow("Branches for " + repo.GetGoPath())
+ pw.win.Make()
+
+ pw.stack = pw.win.Box().NewBox("bw vbox", false)
+ // me.reposwin.Draw()
+ pw.win.Custom = func() {
+ log.Info("Got close. setting win.Hide()")
+ // sets the hidden flag to false so Toggle() works
+ pw.win.Hide()
+ }
+
+ grid := pw.stack.NewGrid("", 0, 0)
+
+ grid.NewGroup("Branches")
+ grid.NextRow()
+
+ grid.NewGroup("Name")
+ grid.NewGroup("Forge use")
+ grid.NewGroup("Ref Version")
+ grid.NewGroup("Type")
+ grid.NewGroup("Hash")
+ grid.NextRow()
+
+ for _, b := range repo.GetLocalBranches() {
+ hash := repo.GetBranchHash(b)
+ grid.NewLabel(b)
+ grid.NewLabel(repo.GetBranchVersion(b))
+ if s, err := repo.GetHashName(hash); err == nil {
+ grid.NewLabel(s)
+ } else {
+ grid.NewLabel("err")
+ }
+ grid.NewLabel("local")
+
+ grid.NewLabel(hash)
+ grid.NewButton("Delete", func() {
+ repo.RunVerbose([]string{"git", "branch", "-D", b})
+ })
+ grid.NextRow()
+ }
+
+ for _, b := range repo.GetRemoteBranches() {
+ hash := repo.GetBranchHash(b)
+ grid.NewLabel(b)
+ forgeuse := repo.GetBranchVersion(b)
+ grid.NewLabel(forgeuse)
+ if s, err := repo.GetHashName(hash); err == nil {
+ grid.NewLabel(s)
+ } else {
+ grid.NewLabel("")
+ }
+ grid.NewLabel("remote")
+
+ grid.NewLabel(hash)
+ if b == "origin/HEAD" || forgeuse == "remote master" {
+ // can't delete these
+ } else {
+ grid.NewButton("Delete Remote", func() {
+ })
+ }
+ grid.NextRow()
+ }
+
+ return pw
+}
diff --git a/new.go b/windowMain.go
index 6a0c81b..3a5f9da 100644
--- a/new.go
+++ b/windowMain.go
@@ -14,26 +14,6 @@ func init() {
windowMap = make(map[string]*RepoStatus)
}
-/*
-// deprecate this
-func ListAllOld() {
-}
-
-// returns the object for the path
-// deprecate this
-func FindPathOld(path string) *RepoStatus {
- if windowMap[path] == nil {
- log.Log(INFO, "FindPath() not initialized yet", path)
- return nil
- }
- return windowMap[path]
-}
-
-func SetWorkPath(path string) {
- os.Setenv("REPO_WORK_PATH", path)
-}
-*/
-
// makes a window of the status of the repo
// don't worry, you can think of it like Sierpinski carpet
// it's doesn't need to be displayed so it'll work fine even in an embedded space
@@ -62,7 +42,7 @@ func NewRepoStatusWindow(repo *gitpb.Repo) (*RepoStatus, error) {
group := basebox.NewGroup("stuff")
primarybox := group.Box()
primarybox.Horizontal()
- box2 := group.Box()
+ // box2 := group.Box()
rs.ready = true
rs.window.Custom = func() {
rs.Hide()
@@ -84,7 +64,7 @@ func NewRepoStatusWindow(repo *gitpb.Repo) (*RepoStatus, error) {
rs.realPath.SetValue(rs.pb.GetFullPath())
// add all the tags
- rs.makeTagBox(box2)
+ // rs.makeTagBox(box2)
// rs.readGitConfig()
diff --git a/windowRepo.go b/windowRepo.go
new file mode 100644
index 0000000..c934f55
--- /dev/null
+++ b/windowRepo.go
@@ -0,0 +1,73 @@
+package repostatus
+
+import (
+ "go.wit.com/lib/gadgets"
+ "go.wit.com/lib/protobuf/gitpb"
+
+ "go.wit.com/gui"
+)
+
+type repoWindow struct {
+ repo *gitpb.Repo // the repo protobuf
+ win *gadgets.BasicWindow // the patches window
+ stack *gui.Node // the top box set as vertical
+ //shelf *gui.Node // the first box in the stack, set as horizontal
+ //grid *gui.Node // the list of available patches
+ //setgrid *gui.Node // the list of each patchset
+}
+
+// todo: autogenerate these or make them standared 'gui' package functions
+// make this an go interface somehow
+
+// is the window hidden right now?
+func (w *repoWindow) Hidden() bool {
+ return w.win.Hidden()
+}
+
+// switches between the window being visable or hidden on the desktop
+func (w *repoWindow) Toggle() {
+ if w.Hidden() {
+ w.Show()
+ } else {
+ w.Hide()
+ }
+}
+
+// hides the window completely
+func (w *repoWindow) Show() {
+ w.win.Show()
+}
+
+func (w *repoWindow) Hide() {
+ w.win.Hide()
+}
+
+// should be the first box/widget in the window
+// greys out the window to the user
+func (w *repoWindow) Disable() {
+ w.stack.Disable()
+}
+
+func (w *repoWindow) Enable() {
+ w.stack.Enable()
+}
+
+// you can only have one of these
+func MakeRepoWindow(repo *gitpb.Repo) *repoWindow {
+ pw := new(repoWindow)
+
+ // sync.Once()
+ pw.win = gadgets.RawBasicWindow("Patcheset for " + repo.GetGoPath())
+ pw.win.Make()
+
+ pw.stack = pw.win.Box().NewBox("bw vbox", false)
+ // me.reposwin.Draw()
+ pw.win.Custom = func() {
+ // sets the hidden flag to false so Toggle() works
+ pw.win.Hide()
+ }
+
+ // grid := pw.stack.NewGrid("", 0, 0)
+
+ return pw
+}