experiment with widget 'mirror'

This commit is contained in:
Jeff Carr 2024-02-19 14:42:59 -06:00
parent be73f6af0e
commit ad21d5d5db
5 changed files with 59 additions and 48 deletions

View File

@ -3,6 +3,7 @@ package repostatus
import (
"strings"
"go.wit.com/gui"
"go.wit.com/log"
// "go.wit.com/gui/gui"
)
@ -41,7 +42,7 @@ func (rs *RepoStatus) GoName() string {
// not sure which name is easier to remember. probably this one
func (rs *RepoStatus) GoPath() string {
return rs.goSrcPath.String()
return rs.goPath.String()
}
// returns the filesystem path to the repo
@ -49,22 +50,6 @@ func (rs *RepoStatus) Path() string {
return rs.realPath.String()
}
/*
func (rs *RepoStatus) GetPath() string {
return rs.path.String()
}
*/
/*
func (rs *RepoStatus) Draw() {
if !rs.Ready() {
return
}
log.Log(CHANGE, "Draw() window ready =", rs.ready)
rs.window.TestDraw()
}
*/
func (rs *RepoStatus) Show() {
if !rs.Ready() {
return
@ -190,3 +175,20 @@ func (rs *RepoStatus) SetTargetVersion(s string) {
// func (rs *RepoStatus) setTag() bool {
rs.targetReleaseVersion.SetText(s)
}
// returns a widget of the last tag that acts as a mirror
func (rs *RepoStatus) MirrorLastTag() *gui.Node {
return rs.lasttag.MirrorValue()
}
func (rs *RepoStatus) MirrorTargetVersion() *gui.Node {
return rs.targetReleaseVersion.MirrorValue()
}
func (rs *RepoStatus) MirrorCurrentVersion() *gui.Node {
return rs.currentVersion.MirrorValue()
}
func (rs *RepoStatus) MirrorCurrentName() *gui.Node {
return rs.currentBranch.MirrorValue()
}

View File

@ -13,6 +13,7 @@ func (rs *RepoStatus) drawGitStatus(box *gui.Node) {
rs.path = gadgets.NewOneLiner(newgrid, "path")
rs.goSrcPath = gadgets.NewOneLiner(newgrid, "~/go/src")
rs.goPath = gadgets.NewOneLiner(newgrid, "go path")
rs.realPath = gadgets.NewOneLiner(newgrid, "full path")
rs.isGoLang = gadgets.NewOneLiner(newgrid, "Is GO Lang?")
rs.isGoLang.SetText("false")

17
new.go
View File

@ -33,6 +33,9 @@ func FindPathOld(path string) *RepoStatus {
}
func NewRepoStatusWindow(path string) (error, *RepoStatus) {
var realpath string
var isGoLang bool = false
if windowMap[path] == nil {
log.Log(INFO, "NewRepoStatusWindow() adding new", path)
} else {
@ -41,8 +44,6 @@ func NewRepoStatusWindow(path string) (error, *RepoStatus) {
return nil, windowMap[path]
}
var realpath string
homeDir, err := os.UserHomeDir()
if err != nil {
log.Log(WARN, "Error getting home directory:", err)
@ -50,6 +51,10 @@ func NewRepoStatusWindow(path string) (error, *RepoStatus) {
}
goSrcDir := filepath.Join(homeDir, "go/src")
rs := &RepoStatus{
ready: false,
}
// allow arbitrary paths, otherwise, assume the repo is in ~/go/src
if strings.HasPrefix(path, "/") {
realpath = path
@ -59,6 +64,7 @@ func NewRepoStatusWindow(path string) (error, *RepoStatus) {
realpath = filepath.Join(homeDir, tmp)
} else {
realpath = filepath.Join(goSrcDir, path)
isGoLang = true
}
filename := filepath.Join(realpath, ".git/config")
@ -70,9 +76,6 @@ func NewRepoStatusWindow(path string) (error, *RepoStatus) {
return err, nil
}
rs := &RepoStatus{
ready: false,
}
rs.tags = make(map[string]string)
rs.window = gadgets.RawBasicWindow("GO Repo Details " + path)
rs.window.Horizontal()
@ -123,6 +126,10 @@ func NewRepoStatusWindow(path string) (error, *RepoStatus) {
// sets this to os.Username
rs.setUserWorkingName()
if isGoLang {
rs.isGoLang.SetText("true")
rs.goPath.SetText(path)
}
windowMap[path] = rs
return nil, rs
}

View File

@ -28,6 +28,7 @@ type RepoStatus struct {
path *gadgets.OneLiner
goSrcPath *gadgets.OneLiner
goPath *gadgets.OneLiner
realPath *gadgets.OneLiner
isGoLang *gadgets.OneLiner