export Status
This commit is contained in:
parent
b298958bcd
commit
985c422217
36
addRepo.go
36
addRepo.go
|
@ -64,7 +64,7 @@ func (r *RepoList) addRepo(grid *gui.Node, path string, master string, devel str
|
|||
}
|
||||
|
||||
newRepo := new(Repo)
|
||||
newRepo.status = rstatus
|
||||
newRepo.Status = rstatus
|
||||
|
||||
path = strings.TrimSuffix(path, "/") // trim any extranous '/' chars put in the config file by the user
|
||||
if path == "" {
|
||||
|
@ -81,31 +81,31 @@ func (r *RepoList) addRepo(grid *gui.Node, path string, master string, devel str
|
|||
newRepo.vLabel = grid.NewLabel("").SetProgName("current")
|
||||
newRepo.endBox = grid.NewHorizontalBox("HBOX")
|
||||
newRepo.endBox.NewButton("Configure", func() {
|
||||
if newRepo.status == nil {
|
||||
if newRepo.Status == nil {
|
||||
log.Warn("status window wasn't created")
|
||||
return
|
||||
}
|
||||
newRepo.status.Toggle()
|
||||
newRepo.Status.Toggle()
|
||||
})
|
||||
|
||||
newRepo.endBox.NewButton("show diff", func() {
|
||||
r.reposbox.Disable()
|
||||
// newRepo.status.XtermNohup([]string{"git diff"})
|
||||
newRepo.status.Xterm("git diff; bash")
|
||||
// newRepo.Status.XtermNohup([]string{"git diff"})
|
||||
newRepo.Status.Xterm("git diff; bash")
|
||||
r.reposbox.Enable()
|
||||
})
|
||||
|
||||
newRepo.endBox.NewButton("commit all", func() {
|
||||
r.reposbox.Disable()
|
||||
// restore anything staged so everything can be reviewed
|
||||
newRepo.status.RunCmd([]string{"git", "restore", "--staged", "."})
|
||||
newRepo.status.XtermWait("git diff")
|
||||
newRepo.status.XtermWait("git add --all")
|
||||
newRepo.status.XtermWait("git commit -a")
|
||||
newRepo.status.XtermWait("git push")
|
||||
if newRepo.status.CheckDirty() {
|
||||
newRepo.Status.RunCmd([]string{"git", "restore", "--staged", "."})
|
||||
newRepo.Status.XtermWait("git diff")
|
||||
newRepo.Status.XtermWait("git add --all")
|
||||
newRepo.Status.XtermWait("git commit -a")
|
||||
newRepo.Status.XtermWait("git push")
|
||||
if newRepo.Status.CheckDirty() {
|
||||
// commit was not done, restore diff
|
||||
newRepo.status.RunCmd([]string{"git", "restore", "--staged", "."})
|
||||
newRepo.Status.RunCmd([]string{"git", "restore", "--staged", "."})
|
||||
} else {
|
||||
newRepo.NewScan()
|
||||
}
|
||||
|
@ -113,23 +113,23 @@ func (r *RepoList) addRepo(grid *gui.Node, path string, master string, devel str
|
|||
})
|
||||
|
||||
newRepo.hidden = false
|
||||
// newRepo.status.SetMainWorkingName(master)
|
||||
// newRepo.status.SetDevelWorkingName(devel)
|
||||
// newRepo.status.SetUserWorkingName(user)
|
||||
// newRepo.Status.SetMainWorkingName(master)
|
||||
// newRepo.Status.SetDevelWorkingName(devel)
|
||||
// newRepo.Status.SetUserWorkingName(user)
|
||||
|
||||
var showBuildB bool = false
|
||||
switch newRepo.status.RepoType() {
|
||||
switch newRepo.Status.RepoType() {
|
||||
case "binary":
|
||||
// log.Info("compile here. Show()")
|
||||
showBuildB = true
|
||||
case "library":
|
||||
// log.Info("library here. Hide()")
|
||||
default:
|
||||
// log.Info("unknown RepoType", newRepo.status.RepoType())
|
||||
// log.Info("unknown RepoType", newRepo.Status.RepoType())
|
||||
}
|
||||
if showBuildB {
|
||||
newRepo.endBox.NewButton("build", func() {
|
||||
newRepo.status.Build()
|
||||
newRepo.Status.Build()
|
||||
})
|
||||
}
|
||||
grid.NextRow()
|
||||
|
|
76
common.go
76
common.go
|
@ -4,21 +4,6 @@ import (
|
|||
"go.wit.com/lib/gui/repostatus"
|
||||
)
|
||||
|
||||
// deprecate this
|
||||
func (r *Repo) String() string {
|
||||
return r.status.String()
|
||||
}
|
||||
|
||||
// full path "/home/username/go/src/go.wit.com/apps/autotypist"
|
||||
func (r *Repo) Path() string {
|
||||
return r.status.Path()
|
||||
}
|
||||
|
||||
// go path "go.wit.com/apps/autotypist"
|
||||
func (r *Repo) GoPath() string {
|
||||
return r.status.GoName()
|
||||
}
|
||||
|
||||
func (r *RepoList) Hidden() bool {
|
||||
return r.reposbox.Hidden()
|
||||
}
|
||||
|
@ -48,55 +33,42 @@ func AllRepos() []*Repo {
|
|||
return all
|
||||
}
|
||||
|
||||
func (r *Repo) Build() bool {
|
||||
return r.status.Build()
|
||||
}
|
||||
|
||||
func (r *Repo) Xterm(s string) {
|
||||
r.status.Xterm(s)
|
||||
}
|
||||
|
||||
func (r *Repo) RepoType() string {
|
||||
return r.status.RepoType()
|
||||
}
|
||||
|
||||
func (r *Repo) Status() string {
|
||||
// a human readable state of the current repo
|
||||
func (r *Repo) State() string {
|
||||
return r.dirtyLabel.String()
|
||||
}
|
||||
|
||||
func (r *Repo) MergeDevelToMaster() bool {
|
||||
return r.status.MergeDevelToMaster()
|
||||
}
|
||||
|
||||
func (r *Repo) MergeUserToDevel() bool {
|
||||
return r.status.MergeUserToDevel()
|
||||
}
|
||||
|
||||
func (r *Repo) Scan() bool {
|
||||
return r.NewScan()
|
||||
}
|
||||
|
||||
// returns a name for human consuption only
|
||||
// todo: implement nicknames
|
||||
func (rs *Repo) Name() string {
|
||||
if rs.Status.IsGoLang() {
|
||||
return rs.Status.GoPath()
|
||||
}
|
||||
return rs.Status.Path()
|
||||
}
|
||||
|
||||
func (r *Repo) Exists(s string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (r *Repo) MakeRedomod() {
|
||||
}
|
||||
|
||||
func (r *Repo) CheckoutBranch(b string) bool {
|
||||
return r.status.CheckoutBranch(b)
|
||||
func (r *Repo) GoPath() string {
|
||||
return r.Status.GoPath()
|
||||
}
|
||||
|
||||
func (r *Repo) CheckDirty() bool {
|
||||
return r.status.CheckDirty()
|
||||
return r.Status.CheckDirty()
|
||||
}
|
||||
|
||||
func (r *Repo) IsDirty() bool {
|
||||
return r.status.IsDirty()
|
||||
return r.Status.IsDirty()
|
||||
}
|
||||
|
||||
func (r *Repo) ReadOnly() bool {
|
||||
return r.status.ReadOnly()
|
||||
return r.Status.ReadOnly()
|
||||
}
|
||||
|
||||
func (r *Repo) IsPerfect() bool {
|
||||
|
@ -110,27 +82,19 @@ func (r *Repo) IsPerfect() bool {
|
|||
}
|
||||
|
||||
func (r *Repo) RunCmd(cmd []string) (error, string) {
|
||||
return r.status.RunCmd(cmd)
|
||||
}
|
||||
|
||||
func (r *Repo) GetDevelBranchName() string {
|
||||
return r.status.GetDevelBranchName()
|
||||
}
|
||||
|
||||
func (r *Repo) GetUserBranchName() string {
|
||||
return r.status.GetUserBranchName()
|
||||
return r.Status.RunCmd(cmd)
|
||||
}
|
||||
|
||||
func (r *Repo) AllTags() []*repostatus.Tag {
|
||||
return r.status.Tags.ListAll()
|
||||
return r.Status.Tags.ListAll()
|
||||
}
|
||||
|
||||
func (r *Repo) TagsBox() *repostatus.GitTagBox {
|
||||
return r.status.Tags
|
||||
return r.Status.Tags
|
||||
}
|
||||
|
||||
// todo, fix bool return for deletetag()
|
||||
func (r *Repo) DeleteTag(t *repostatus.Tag) bool {
|
||||
r.status.DeleteTag(t)
|
||||
r.Status.DeleteTag(t)
|
||||
return true
|
||||
}
|
||||
|
|
2
new.go
2
new.go
|
@ -27,7 +27,7 @@ func splitLine(line string) (string, string, string, string) {
|
|||
|
||||
func RepoType() {
|
||||
for _, repo := range me.allrepos {
|
||||
switch repo.status.RepoType() {
|
||||
switch repo.Status.RepoType() {
|
||||
case "binary":
|
||||
//log.Info("compile here. Show()")
|
||||
repo.Show()
|
||||
|
|
30
scan.go
30
scan.go
|
@ -26,48 +26,48 @@ func (r *RepoList) ScanRepositories() (int, string) {
|
|||
}
|
||||
|
||||
func (r *Repo) NewScan() bool {
|
||||
if r.status == nil {
|
||||
log.Warn("repo.status = nil. not initialized for some reason")
|
||||
if r.Status == nil {
|
||||
log.Warn("repo.Status = nil. not initialized for some reason")
|
||||
return false
|
||||
}
|
||||
|
||||
// first run the repostatus update
|
||||
r.status.UpdateNew()
|
||||
r.Status.UpdateNew()
|
||||
|
||||
// now read those values and display them in our table
|
||||
mname := r.status.GetMasterBranchName()
|
||||
mver := r.status.GetMasterVersion()
|
||||
mname := r.Status.GetMasterBranchName()
|
||||
mver := r.Status.GetMasterVersion()
|
||||
mver = mver + " (" + mname + ")"
|
||||
r.masterVersion.SetLabel(mver)
|
||||
|
||||
dname := r.status.GetDevelBranchName()
|
||||
dver := r.status.GetDevelVersion()
|
||||
dname := r.Status.GetDevelBranchName()
|
||||
dver := r.Status.GetDevelVersion()
|
||||
if dname != "devel" {
|
||||
dver = dver + " (" + dname + ")"
|
||||
}
|
||||
r.develVersion.SetLabel(dver)
|
||||
|
||||
uname := r.status.GetUserBranchName()
|
||||
uver := r.status.GetUserVersion()
|
||||
uname := r.Status.GetUserBranchName()
|
||||
uver := r.Status.GetUserVersion()
|
||||
usr, _ := user.Current()
|
||||
if uname != usr.Username {
|
||||
uver = uver + " (" + uname + ")"
|
||||
}
|
||||
r.userVersion.SetLabel(uver)
|
||||
|
||||
cbname := r.status.GetCurrentBranchName()
|
||||
cbversion := r.status.GetCurrentBranchVersion()
|
||||
lasttag := r.status.GetLastTagVersion()
|
||||
cbname := r.Status.GetCurrentBranchName()
|
||||
cbversion := r.Status.GetCurrentBranchVersion()
|
||||
lasttag := r.Status.GetLastTagVersion()
|
||||
r.lastTag.SetLabel(lasttag)
|
||||
r.vLabel.SetLabel(cbname + " " + cbversion)
|
||||
|
||||
if c, ok := r.status.Changed(); ok {
|
||||
if c, ok := r.Status.Changed(); ok {
|
||||
c := strings.TrimSpace(c)
|
||||
for _, line := range strings.Split(c, "\n") {
|
||||
log.Info(r.status.Path(), line)
|
||||
log.Info(r.Status.Path(), line)
|
||||
}
|
||||
}
|
||||
status := r.status.GetStatus()
|
||||
status := r.Status.GetStatus()
|
||||
r.dirtyLabel.SetLabel(status)
|
||||
if status == "PERFECT" {
|
||||
if me.autoHidePerfect {
|
||||
|
|
|
@ -50,5 +50,5 @@ type Repo struct {
|
|||
statusButton *gui.Node // opens up the status window
|
||||
diffButton *gui.Node // opens up the status window
|
||||
|
||||
status *repostatus.RepoStatus
|
||||
Status *repostatus.RepoStatus
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue