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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
|
// This is a simple example
package main
import (
"io/ioutil"
"strings"
"go.wit.com/log"
"go.wit.com/gui/gui"
"go.wit.com/gui/gadgets"
"go.wit.com/gui/gadgets/repostatus"
"go.wit.com/apps/control-panel-dns/smartwindow"
)
var myGui *gui.Node
var allrepos []*repo
type repo struct {
path string
lasttagrev string
lasttag string
tags []string
pLabel *gui.Node // path label
bLabel *gui.Node // branch label
lastLabel *gui.Node // last tagged version label
vLabel *gui.Node // version label
// tagsDrop *gui.Node // list of all tags
dirtyLabel *gui.Node // git state (dirty or not?)
masterVersion *gui.Node // the master branch version
develVersion *gui.Node // the devel branch version
jcarrVersion *gui.Node // the jcarr branch version
cButton *gui.Node // commit button
pButton *gui.Node // push button
status *repostatus.RepoStatus
}
func main() {
myGui = gui.New().Default()
repoworld()
/*
for i, r := range allrepos {
log.Warn("scannning", i, r.path)
r.scan()
}
*/
gui.Watchdog()
}
func (r *repo) getPath() string {
return r.path
}
func addRepo(grid *gui.Node, path string) {
newRepo := new(repo)
if repostatus.VerifyLocalGoRepo(path) {
log.Warn("newRepo actually exists", newRepo.getPath())
} else {
log.Warn("newRepo does not exist", newRepo.getPath())
return
}
newRepo.path = path
newRepo.pLabel = grid.NewLabel(path)
newRepo.bLabel = grid.NewLabel("")
newRepo.lastLabel = grid.NewLabel("")
newRepo.vLabel = grid.NewLabel("")
// newRepo.tagsDrop = grid.NewDropdown("tags")
newRepo.masterVersion = grid.NewLabel("")
newRepo.develVersion = grid.NewLabel("")
newRepo.jcarrVersion = grid.NewLabel("")
newRepo.dirtyLabel = grid.NewLabel("")
/*
newRepo.cButton = grid.NewButton("status", func () {
log.Println("repo status for", newRepo.path)
newRepo.scan()
if newRepo.status == nil {
newRepo.status = repostatus.New(myGui, newRepo.path)
newRepo.status.Vertical()
newRepo.status.Horizontal()
newRepo.status.Make()
newRepo.status.Draw()
newRepo.status.Draw2()
}
newRepo.status.Toggle()
})
*/
newRepo.pButton = grid.NewButton("rescan", func () {
newRepo.newScan()
})
/*
grid.NewButton("SierpiĆski", func () {
if newRepo.status != nil {
log.Warn("status window already exists")
}
newRepo.status = repostatus.New(myGui, newRepo.path)
newRepo.status.Horizontal()
newRepo.status.Make()
newRepo.status.Make2()
})
*/
grid.NewButton("Toggle()", func () {
if newRepo.status == nil {
log.Warn("status window doesn't exist")
return
}
log.Warn("status window exists. trying Update() here")
newRepo.status.Toggle()
})
grid.NewButton("TestDraw()", func () {
if newRepo.status == nil {
log.Warn("status window doesn't exist")
return
}
log.Warn("status window exists. trying TestDraw() here")
newRepo.status.TestDraw()
})
if path == "" {
newRepo.cButton.Hide()
newRepo.pButton.Hide()
}
newRepo.status = repostatus.New(myGui, newRepo.path)
newRepo.status.Horizontal()
newRepo.status.Make()
newRepo.status.Make2()
newRepo.status.Update()
newRepo.newScan()
allrepos = append(allrepos, newRepo)
}
// This creates a window
func repoworld() {
win := gadgets.NewBasicWindow(myGui, "git autotypist. it types faster than you can.")
box := win.Box().NewBox("bw vbox", false)
// box2 := win.Box().NewBox("bw vbox", false)
group := box.NewGroup("go repositories (read from ~/.config/myrepolist)")
grid := group.NewGrid("test", 11, 1)
grid.NewLabel("")
grid.NewLabel("branch")
grid.NewLabel("last tag")
grid.NewLabel("Current Version")
// grid.NewLabel("tags")
grid.NewLabel("master")
grid.NewLabel("devel")
grid.NewLabel("jcarr")
grid.NewLabel("Status")
grid.NewLabel("commit")
grid.NewLabel("Toggle()")
grid.NewLabel("Draw()")
repos := myrepolist()
for _, repo := range repos {
log.Warn("repo =", repo)
addRepo(grid, repo)
}
win.Draw()
}
// This creates a window
func hellosmart() {
win := smartwindow.New()
win.SetParent(myGui)
win.InitWindow()
win.Title("hellosmart test")
win.Vertical()
win.SetDraw(smartDraw)
win.Make()
win.Box().NewButton("test smartwindow", func () {
log.Println("smart")
})
}
func smartDraw(sw *smartwindow.SmartWindow) {
sw.Box().NewButton("hello", func () {
log.Println("smart")
})
}
func myrepolist() []string {
content, _ := ioutil.ReadFile("/home/jcarr/.config/myrepolist")
out := string(content)
out = strings.TrimSpace(out)
lines := strings.Split(out, "\n")
return lines
}
func (r *repo) newScan() bool {
if r.status == nil {
log.Warn("repo.status = nil. not initialized for some reason")
return false
}
// r.scan()
if repostatus.VerifyLocalGoRepo(r.getPath()) {
log.Warn("repo actually exists", r.getPath())
} else {
log.Warn("repo does not exist", r.getPath())
return false
}
mn := r.status.GetMasterName()
mv := r.status.GetMasterVersion()
r.masterVersion.Set(mn + " " + mv)
dn := r.status.GetDevelName()
dv := r.status.GetDevelVersion()
r.develVersion.Set(dn + " " + dv)
un := r.status.GetUserName()
uv := r.status.GetUserVersion()
r.jcarrVersion.Set(un + " " + uv)
cbname := r.status.GetCurrentBranchName()
cbversion := r.status.GetCurrentBranchVersion()
ltversion := r.status.GetLastTagVersion()
r.lastLabel.Set(cbname + " " + cbversion)
r.vLabel.Set(cbname + " " + ltversion)
if r.status.CheckDirty() {
log.Warn("CheckDirty() true")
r.dirtyLabel.Set("dirty")
return false
}
log.Warn("CheckDirty() no")
r.dirtyLabel.Set("not dirty")
if r.status.CheckBranches() {
log.Warn("Branches are Perfect")
r.dirtyLabel.SetText("PEFECT")
return true
} else {
log.Warn("Branches are not Perfect")
r.dirtyLabel.SetText("merge")
}
return false
}
|