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
|
// This is a simple example
package main
import (
"os"
"strings"
"go.wit.com/log"
"go.wit.com/gui"
"go.wit.com/lib/gadgets"
"go.wit.com/lib/gui/repostatus"
)
func doesExist(path string) bool {
if _, err := os.Stat(path); err != nil {
if os.IsNotExist(err) {
return false
}
}
return true
}
// only errors on bad errors
func quickCmd(fullpath string, cmd []string) bool {
var err error
var b bool
var output string
log.Warn("RUN:", fullpath, cmd)
err, b, output = repostatus.RunCmd(fullpath, cmd)
if err != nil {
log.Error(err)
return false
} else if !b {
log.Warn("b =", b)
log.Warn("output =", string(output))
return true
}
log.Warn("output = ", string(output))
return true
}
func globalBuildOptions(box *gui.Node) {
var setCurrentBranch *gui.Node
group1 := box.NewGroup("Global Build Options")
groupvbox := group1.NewBox("bw vbox", false)
// grouphbox := groupvbox.NewBox("bw hbox", true)
grid := groupvbox.NewGrid("buildOptions", 2, 1)
me.mainBranch = gadgets.NewBasicCombobox(grid, "default main branch")
me.mainBranch.AddText("guimain")
me.mainBranch.AddText("gitea server default")
me.mainBranch.Disable()
me.develBranch = gadgets.NewBasicCombobox(grid, "default devel branch")
me.develBranch.AddText("devel")
me.userBranch = gadgets.NewBasicCombobox(grid, "default user branch")
me.userBranch.AddText("jcarr")
// select the branch you want to test, build and develop against
// this lets you select your user branch, but, when you are happy
// you can merge everything into the devel branch and make sure it actually
// works. Then, when that is good, merge and version everything in master
guiBranch := gadgets.NewBasicCombobox(grid, "Set Current Working Branch")
guiBranch.AddText("guimaster")
guiBranch.AddText("guidevel")
guiBranch.AddText("jcarr")
guiBranch.Custom = func() {
me.toMoveToBranch = guiBranch.String()
setCurrentBranch.Set("set all branches to " + me.toMoveToBranch)
me.mainBranch.Disable()
}
groupvbox.NewButton("rebuild autotypist", func() {
fullpath := "/home/jcarr/go/src"
quickCmd(fullpath, []string{"mkdir", "-p", "go.wit.com/apps/"})
fullpath = "/home/jcarr/go/src/go.wit.com/apps/autotypist"
quickCmd(fullpath, []string{"go", "get", "-v", "-u", "go.wit.com/apps/autotypist"})
quickCmd(fullpath, []string{"go", "get", "-v", "-u", "go.wit.com/toolkits/debian"})
fullpath = "/home/jcarr/go/src/go.wit.com/toolkits/debian"
quickCmd(fullpath, []string{"make"})
fullpath = "/home/jcarr/go/src/go.wit.com/apps/autotypist"
quickCmd(fullpath, []string{"go", "-v", "-x", "build"})
})
me.rerunGoMod = groupvbox.NewButton("re-run go mod & go tidy", func() {
me.rerunGoMod.Disable()
log.Warn("scanning allrepos")
os.Unsetenv("GO111MODULE")
for _, path := range me.allrepos {
fullpath := "/home/jcarr/go/src/" + path
// set the button text for the user
me.rerunGoMod.SetText("Running go.mod " + fullpath)
quickCmd(fullpath, []string{"pwd"})
quickCmd(fullpath, []string{"ls", "-l"})
quickCmd(fullpath, []string{"git", "status"}) // TODO: process this?
quickCmd(fullpath, []string{"rm", "go.mod", "go.sum"})
quickCmd(fullpath, []string{"go", "mod", "init"})
log.Sleep(.1) // don't hammer google's golang versioning system
quickCmd(fullpath, []string{"go", "mod", "tidy"})
log.Sleep(.2) // don't hammer google's golang versioning system
quickCmd(fullpath, []string{"git", "status"}) // TODO: process this?
}
// re-enable the button
me.rerunGoMod.SetText("re-run go mod & go tidy")
me.rerunGoMod.Enable()
})
setCurrentBranch = groupvbox.NewButton("set all branches to", func() {
log.Warn("scanning allrepos")
for repo, path := range me.allrepos {
log.Warn("found repo", repo.String())
var changeBranch [][]string
// realname, realversion := repo.status.CheckoutBranch(me.toMoveToBranch)
// log.Warn("GOT", realname, realversion)
// path := repo.status.GetPath()
changeBranch = append(changeBranch, []string{"cd", "go/src/" + path})
changeBranch = append(changeBranch, []string{"git", "checkout", me.toMoveToBranch})
me.script = changeBranch
setGitCommands()
// goMake("--doit")
}
})
var everything *gui.Node
everything = groupvbox.NewButton("go get everything on go.wit.com", func() {
var perfect bool = true
var newCmds [][]string
// usr, _ := user.Current()
newCmds = append(newCmds, []string{"cd", "go/src/go.wit.com/apps/myrepos"})
repos := myrepolist()
for _, line := range repos {
log.Warn("repo =", line)
path, _, _, _ := splitLine(line)
path = strings.TrimSpace(path)
if path == "#" {
// skip comment lines
continue
}
if doesExist("/home/jcarr/go/src/" + path) {
continue
}
newCmds = append(newCmds, []string{"go", "get", "-v", path})
perfect = false
}
if perfect {
var notes [][]string
notes = append(notes, []string{"you have already downloaded"})
notes = append(notes, []string{"everything on go.wit.com"})
me.script = notes
setGitCommands()
doit.Disable()
everything.Disable()
return
}
me.script = newCmds
doit.Enable()
setGitCommands()
})
groupvbox.NewButton("build all apps", func() {
})
}
|