delete old code. start refactor to protobuf
This commit is contained in:
parent
2b2de94eff
commit
2395a4466e
|
@ -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.checkBranchesButton = newgrid.NewButton("CheckBranches()", func() {
|
||||
log.Info("redo this")
|
||||
})
|
||||
newgrid.NextRow()
|
||||
|
||||
newgrid.NewButton("Revert master to devel", func() {
|
||||
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()
|
||||
|
||||
newgrid.NewButton("Revert master to devel", func() {
|
||||
log.Info("redo this")
|
||||
})
|
||||
*/
|
||||
|
||||
var win *repoBranchesWindow
|
||||
newgrid.NewButton("Branches Window", func() {
|
||||
if win != nil {
|
||||
win.Toggle()
|
||||
return
|
||||
}
|
||||
log.Info("redo this")
|
||||
win = MakeRepoBranchesWindow(rs.pb)
|
||||
win.Show()
|
||||
})
|
||||
}
|
||||
|
|
4
git.go
4
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()
|
||||
|
|
35
update.go
35
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")
|
||||
}
|
||||
*/
|
||||
|
|
|
@ -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
|
||||
}
|
|
@ -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()
|
||||
|
|
@ -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
|
||||
}
|
Loading…
Reference in New Issue