repostatus/windowMain.go

63 lines
1.5 KiB
Go

package repostatus
import (
"go.wit.com/lib/gadgets"
"go.wit.com/lib/protobuf/gitpb"
"go.wit.com/log"
)
var windowMap map[string]*RepoStatus
func init() {
windowMap = make(map[string]*RepoStatus)
}
// 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
func NewRepoStatusWindow(repo *gitpb.Repo) (*RepoStatus, error) {
path := repo.GetGoPath()
if windowMap[path] == nil {
log.Log(INFO, "NewRepoStatusWindow() adding new", path)
} else {
log.Warn("This already exists for path", path)
log.Warn("should return windowMap[path] here")
return windowMap[path], nil
}
rs := &RepoStatus{
ready: false,
}
rs.pb = repo
// realpath := repo.FullPath
// isGoLang := true
// rs.tags = make(map[string]string)
rs.window = gadgets.RawBasicWindow("GO Repo Details " + path)
rs.window.Horizontal()
rs.window.Make()
basebox := rs.window.Box()
group := basebox.NewGroup("stuff")
primarybox := group.Box()
primarybox.Horizontal()
// box2 := group.Box()
rs.ready = true
rs.window.Custom = func() {
rs.Hide()
log.Warn("repostatus user closed the window()")
}
// display the status of the git repository
rs.drawGitStatus(primarybox)
// display the git branches and options
rs.makeBranchesBox(primarybox)
// var win *gadgets.BasicWindow
// show standard git commit and merge controls
rs.drawGitCommands(primarybox)
windowMap[path] = rs
return rs, nil
}