1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
package repolist
import (
"go.wit.com/gui"
"go.wit.com/log"
)
// This creates a view of the repos
// you can only have one at this point
func TempWindowView(parent *gui.Node) *RepoList {
tmp := new(RepoList)
tmp.viewName = "autotypist"
// me.reposbox = gui.RawBox()
tmp.reposbox = parent
tmp.reposgroup = tmp.reposbox.NewGroup("git repositories that are not merged")
tmp.reposgrid = tmp.reposgroup.NewGrid("mergegrid", 0, 0)
tmp.reposgrid.NewLabel("") // path goes here
tmp.reposgrid.NewLabel("Current Branch")
tmp.reposgrid.NewLabel("last tag")
tmp.reposgrid.NewLabel("master")
tmp.reposgrid.NewLabel("devel")
tmp.reposgrid.NewLabel("user")
tmp.reposgrid.NewLabel("?")
tmp.reposgrid.NextRow()
tmp.shownCount = me.blind.NewLabel("showCount")
tmp.duration = me.blind.NewLabel("duration")
return tmp
}
func (r *RepoList) ShowRepo(repo *RepoRow) error {
// this is the gui grid. all the widgets get added here
// at the end we tell the grid go to NextRow()
grid := r.reposgrid
// make a new row of gui widgets
newRow := new(RepoRow)
newRow.Status = repo.Status
newRow.pLabel = grid.NewLabel(repo.Status.Path())
newRow.currentName = grid.NewLabel(repo.Status.GetCurrentBranchName())
newRow.lastTag = grid.NewLabel(repo.Status.LastTag())
newRow.masterVersion = grid.NewLabel(repo.Status.GetMasterVersion())
newRow.develVersion = grid.NewLabel(repo.Status.GetDevelVersion())
newRow.userVersion = grid.NewLabel(repo.Status.GetUserVersion())
newRow.gitState = grid.NewLabel(repo.Status.GitState())
newRow.endBox = grid.NewHorizontalBox("HBOX")
newRow.endBox.NewButton("Repo Window", func() {
newRow.Status.Toggle()
})
newRow.endBox.NewButton("show diff", func() {
log.Log(REPOWARN, "show diff currentName =", newRow.currentName.String())
log.Log(REPOWARN, "show diff masterVersion =", newRow.masterVersion.String())
// newRow.Status.XtermNohup([]string{"git diff"})
newRow.Status.Xterm("git diff; bash")
})
newRow.endBox.NewButton("commit all", func() {
if !newRow.Status.IsUserBranch() {
log.Log(REPOWARN, "can not commit on non user branch")
return
}
// restore anything staged so everything can be reviewed
newRow.Status.RunCmd([]string{"git", "restore", "--staged", "."})
newRow.Status.XtermWait("git diff")
newRow.Status.XtermWait("git add --all")
newRow.Status.XtermWait("git commit -a")
newRow.Status.XtermWait("git push")
if newRow.Status.CheckDirty() {
// commit was not done, restore diff
newRow.Status.RunCmd([]string{"git", "restore", "--staged", "."})
} else {
newRow.NewScan()
}
})
newRow.hidden = false
r.reposgrid.NextRow()
return nil
}
|