experiment with widget 'mirror'
This commit is contained in:
parent
be73f6af0e
commit
ad21d5d5db
36
common.go
36
common.go
|
@ -3,6 +3,7 @@ package repostatus
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"go.wit.com/gui"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
// "go.wit.com/gui/gui"
|
// "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
|
// not sure which name is easier to remember. probably this one
|
||||||
func (rs *RepoStatus) GoPath() string {
|
func (rs *RepoStatus) GoPath() string {
|
||||||
return rs.goSrcPath.String()
|
return rs.goPath.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns the filesystem path to the repo
|
// returns the filesystem path to the repo
|
||||||
|
@ -49,22 +50,6 @@ func (rs *RepoStatus) Path() string {
|
||||||
return rs.realPath.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() {
|
func (rs *RepoStatus) Show() {
|
||||||
if !rs.Ready() {
|
if !rs.Ready() {
|
||||||
return
|
return
|
||||||
|
@ -190,3 +175,20 @@ func (rs *RepoStatus) SetTargetVersion(s string) {
|
||||||
// func (rs *RepoStatus) setTag() bool {
|
// func (rs *RepoStatus) setTag() bool {
|
||||||
rs.targetReleaseVersion.SetText(s)
|
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()
|
||||||
|
}
|
||||||
|
|
1
draw.go
1
draw.go
|
@ -13,6 +13,7 @@ func (rs *RepoStatus) drawGitStatus(box *gui.Node) {
|
||||||
|
|
||||||
rs.path = gadgets.NewOneLiner(newgrid, "path")
|
rs.path = gadgets.NewOneLiner(newgrid, "path")
|
||||||
rs.goSrcPath = gadgets.NewOneLiner(newgrid, "~/go/src")
|
rs.goSrcPath = gadgets.NewOneLiner(newgrid, "~/go/src")
|
||||||
|
rs.goPath = gadgets.NewOneLiner(newgrid, "go path")
|
||||||
rs.realPath = gadgets.NewOneLiner(newgrid, "full path")
|
rs.realPath = gadgets.NewOneLiner(newgrid, "full path")
|
||||||
rs.isGoLang = gadgets.NewOneLiner(newgrid, "Is GO Lang?")
|
rs.isGoLang = gadgets.NewOneLiner(newgrid, "Is GO Lang?")
|
||||||
rs.isGoLang.SetText("false")
|
rs.isGoLang.SetText("false")
|
||||||
|
|
17
new.go
17
new.go
|
@ -33,6 +33,9 @@ func FindPathOld(path string) *RepoStatus {
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewRepoStatusWindow(path string) (error, *RepoStatus) {
|
func NewRepoStatusWindow(path string) (error, *RepoStatus) {
|
||||||
|
var realpath string
|
||||||
|
var isGoLang bool = false
|
||||||
|
|
||||||
if windowMap[path] == nil {
|
if windowMap[path] == nil {
|
||||||
log.Log(INFO, "NewRepoStatusWindow() adding new", path)
|
log.Log(INFO, "NewRepoStatusWindow() adding new", path)
|
||||||
} else {
|
} else {
|
||||||
|
@ -41,8 +44,6 @@ func NewRepoStatusWindow(path string) (error, *RepoStatus) {
|
||||||
return nil, windowMap[path]
|
return nil, windowMap[path]
|
||||||
}
|
}
|
||||||
|
|
||||||
var realpath string
|
|
||||||
|
|
||||||
homeDir, err := os.UserHomeDir()
|
homeDir, err := os.UserHomeDir()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Log(WARN, "Error getting home directory:", err)
|
log.Log(WARN, "Error getting home directory:", err)
|
||||||
|
@ -50,6 +51,10 @@ func NewRepoStatusWindow(path string) (error, *RepoStatus) {
|
||||||
}
|
}
|
||||||
goSrcDir := filepath.Join(homeDir, "go/src")
|
goSrcDir := filepath.Join(homeDir, "go/src")
|
||||||
|
|
||||||
|
rs := &RepoStatus{
|
||||||
|
ready: false,
|
||||||
|
}
|
||||||
|
|
||||||
// allow arbitrary paths, otherwise, assume the repo is in ~/go/src
|
// allow arbitrary paths, otherwise, assume the repo is in ~/go/src
|
||||||
if strings.HasPrefix(path, "/") {
|
if strings.HasPrefix(path, "/") {
|
||||||
realpath = path
|
realpath = path
|
||||||
|
@ -59,6 +64,7 @@ func NewRepoStatusWindow(path string) (error, *RepoStatus) {
|
||||||
realpath = filepath.Join(homeDir, tmp)
|
realpath = filepath.Join(homeDir, tmp)
|
||||||
} else {
|
} else {
|
||||||
realpath = filepath.Join(goSrcDir, path)
|
realpath = filepath.Join(goSrcDir, path)
|
||||||
|
isGoLang = true
|
||||||
}
|
}
|
||||||
|
|
||||||
filename := filepath.Join(realpath, ".git/config")
|
filename := filepath.Join(realpath, ".git/config")
|
||||||
|
@ -70,9 +76,6 @@ func NewRepoStatusWindow(path string) (error, *RepoStatus) {
|
||||||
return err, nil
|
return err, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
rs := &RepoStatus{
|
|
||||||
ready: false,
|
|
||||||
}
|
|
||||||
rs.tags = make(map[string]string)
|
rs.tags = make(map[string]string)
|
||||||
rs.window = gadgets.RawBasicWindow("GO Repo Details " + path)
|
rs.window = gadgets.RawBasicWindow("GO Repo Details " + path)
|
||||||
rs.window.Horizontal()
|
rs.window.Horizontal()
|
||||||
|
@ -123,6 +126,10 @@ func NewRepoStatusWindow(path string) (error, *RepoStatus) {
|
||||||
// sets this to os.Username
|
// sets this to os.Username
|
||||||
rs.setUserWorkingName()
|
rs.setUserWorkingName()
|
||||||
|
|
||||||
|
if isGoLang {
|
||||||
|
rs.isGoLang.SetText("true")
|
||||||
|
rs.goPath.SetText(path)
|
||||||
|
}
|
||||||
windowMap[path] = rs
|
windowMap[path] = rs
|
||||||
return nil, rs
|
return nil, rs
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ type RepoStatus struct {
|
||||||
|
|
||||||
path *gadgets.OneLiner
|
path *gadgets.OneLiner
|
||||||
goSrcPath *gadgets.OneLiner
|
goSrcPath *gadgets.OneLiner
|
||||||
|
goPath *gadgets.OneLiner
|
||||||
realPath *gadgets.OneLiner
|
realPath *gadgets.OneLiner
|
||||||
isGoLang *gadgets.OneLiner
|
isGoLang *gadgets.OneLiner
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue