2024-02-22 19:28:23 -06:00
|
|
|
package repolist
|
|
|
|
|
|
|
|
import (
|
2024-12-01 11:44:02 -06:00
|
|
|
"errors"
|
|
|
|
|
2024-02-22 19:28:23 -06:00
|
|
|
"go.wit.com/lib/gui/repostatus"
|
2024-11-28 18:27:38 -06:00
|
|
|
"go.wit.com/lib/protobuf/gitpb"
|
2024-02-22 19:28:23 -06:00
|
|
|
"go.wit.com/log"
|
|
|
|
)
|
|
|
|
|
2024-02-23 09:02:51 -06:00
|
|
|
func (r *RepoRow) Hidden() bool {
|
2024-02-22 21:12:35 -06:00
|
|
|
return r.hidden
|
|
|
|
}
|
|
|
|
|
2024-02-23 09:02:51 -06:00
|
|
|
func (r *RepoRow) Hide() {
|
2024-02-22 21:12:35 -06:00
|
|
|
r.pLabel.Hide()
|
|
|
|
r.lastTag.Hide()
|
|
|
|
r.currentName.Hide()
|
|
|
|
r.currentVersion.Hide()
|
|
|
|
|
|
|
|
r.masterVersion.Hide()
|
|
|
|
r.develVersion.Hide()
|
|
|
|
r.userVersion.Hide()
|
|
|
|
|
|
|
|
r.gitState.Hide()
|
|
|
|
r.endBox.Hide()
|
|
|
|
r.targetV.Hide()
|
|
|
|
r.hidden = true
|
|
|
|
}
|
|
|
|
|
2024-02-23 09:02:51 -06:00
|
|
|
func (r *RepoRow) Show() {
|
2024-02-22 21:12:35 -06:00
|
|
|
r.pLabel.Show()
|
|
|
|
r.lastTag.Show()
|
|
|
|
r.currentName.Show()
|
|
|
|
r.currentVersion.Show()
|
|
|
|
|
|
|
|
r.masterVersion.Show()
|
|
|
|
r.develVersion.Show()
|
|
|
|
r.userVersion.Show()
|
|
|
|
|
|
|
|
r.gitState.Show()
|
|
|
|
r.endBox.Show()
|
2024-11-05 01:02:00 -06:00
|
|
|
r.targetV.Show()
|
|
|
|
r.hidden = false
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *RepoRow) Show2() {
|
|
|
|
r.pLabel.Show()
|
|
|
|
r.lastTag.Show()
|
|
|
|
r.currentName.Show()
|
|
|
|
r.currentVersion.Show()
|
|
|
|
|
|
|
|
r.masterVersion.Show()
|
|
|
|
r.develVersion.Show()
|
|
|
|
r.userVersion.Show()
|
|
|
|
|
|
|
|
r.gitState.Show()
|
|
|
|
r.endBox.Show()
|
2024-02-22 21:12:35 -06:00
|
|
|
r.targetV.Show()
|
|
|
|
r.hidden = false
|
|
|
|
}
|
|
|
|
|
2024-11-28 18:27:38 -06:00
|
|
|
// adds a gui row to the table based off the repo protobuf
|
2024-11-28 21:03:23 -06:00
|
|
|
func (r *RepoList) AddRepo(pb *gitpb.Repo) (*RepoRow, error) {
|
2024-12-01 11:44:02 -06:00
|
|
|
if !pb.IsDirectory() {
|
|
|
|
// this directory doesn't exist anymore
|
|
|
|
// was moved, or isn't in the ~/go/src or wherever go.work is
|
|
|
|
return nil, errors.New("path is gone: " + pb.FullPath)
|
|
|
|
}
|
2024-11-28 21:03:23 -06:00
|
|
|
test, ok := r.allrepos[pb.GetGoPath()]
|
2024-11-28 18:27:38 -06:00
|
|
|
if ok {
|
2024-12-01 11:44:02 -06:00
|
|
|
// this repo gopath was already added
|
2024-11-28 18:27:38 -06:00
|
|
|
return test, nil
|
|
|
|
}
|
|
|
|
|
2024-11-28 21:03:23 -06:00
|
|
|
status, err := repostatus.NewRepoStatusWindow(pb)
|
2024-11-28 18:27:38 -06:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
newRepo := new(RepoRow)
|
|
|
|
newRepo.Status = status
|
2024-11-28 21:03:23 -06:00
|
|
|
newRepo.pb = pb
|
2024-11-28 18:27:38 -06:00
|
|
|
newRepo.Status.InitOk = false
|
|
|
|
|
2024-12-17 06:36:28 -06:00
|
|
|
newRepo.pLabel = r.reposgrid.NewLabel(pb.GetGoPath()).SetProgName("path")
|
2024-11-28 18:27:38 -06:00
|
|
|
newRepo.hidden = false
|
|
|
|
|
2024-12-17 06:36:28 -06:00
|
|
|
r.allrepos[pb.GetGoPath()] = newRepo
|
2024-11-29 02:01:43 -06:00
|
|
|
// newRepo.NewScan()
|
|
|
|
|
|
|
|
newRepo.lastTag = r.reposgrid.NewLabel("")
|
|
|
|
newRepo.masterVersion = r.reposgrid.NewLabel("")
|
|
|
|
newRepo.develVersion = r.reposgrid.NewLabel("")
|
|
|
|
newRepo.userVersion = r.reposgrid.NewLabel("")
|
|
|
|
newRepo.gitState = r.reposgrid.NewLabel("")
|
|
|
|
newRepo.currentName = r.reposgrid.NewLabel("")
|
|
|
|
newRepo.currentVersion = r.reposgrid.NewLabel("")
|
|
|
|
|
2024-11-29 02:13:50 -06:00
|
|
|
newRepo.endBox = r.reposgrid.NewHorizontalBox("HBOX")
|
2024-02-22 19:28:23 -06:00
|
|
|
newRepo.endBox.NewButton("Configure", func() {
|
|
|
|
newRepo.Status.Toggle()
|
|
|
|
})
|
|
|
|
|
|
|
|
newRepo.endBox.NewButton("show diff", func() {
|
|
|
|
r.reposbox.Disable()
|
|
|
|
log.Log(REPOWARN, "show diff currentName =", newRepo.currentName.String())
|
|
|
|
log.Log(REPOWARN, "show diff masterVersion =", newRepo.masterVersion.String())
|
|
|
|
// newRepo.Status.XtermNohup([]string{"git diff"})
|
|
|
|
newRepo.Status.Xterm("git diff; bash")
|
|
|
|
r.reposbox.Enable()
|
|
|
|
})
|
|
|
|
|
|
|
|
newRepo.endBox.NewButton("commit all", func() {
|
2024-02-25 13:10:23 -06:00
|
|
|
if !newRepo.Status.IsUserBranch() {
|
2024-02-24 04:49:31 -06:00
|
|
|
log.Log(REPOWARN, "can not commit on non user branch")
|
|
|
|
return
|
|
|
|
}
|
2024-02-22 19:28:23 -06:00
|
|
|
r.reposbox.Disable()
|
|
|
|
// restore anything staged so everything can be reviewed
|
2024-11-08 06:43:45 -06:00
|
|
|
newRepo.Status.Run([]string{"git", "restore", "--staged", "."})
|
2024-02-22 19:28:23 -06:00
|
|
|
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
|
2024-11-08 06:43:45 -06:00
|
|
|
newRepo.Status.Run([]string{"git", "restore", "--staged", "."})
|
2024-02-22 19:28:23 -06:00
|
|
|
} else {
|
|
|
|
newRepo.NewScan()
|
|
|
|
}
|
|
|
|
r.reposbox.Enable()
|
|
|
|
})
|
|
|
|
|
2024-11-29 02:13:50 -06:00
|
|
|
r.reposgrid.NextRow()
|
|
|
|
newRepo.Status.InitOk = true
|
|
|
|
return newRepo, nil
|
2024-02-22 19:28:23 -06:00
|
|
|
}
|