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
|
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
// Use of this source code is governed by the GPL 3.0
package main
// An app to submit patches for the 30 GO GUI repos
import (
"os"
"os/user"
"path/filepath"
"time"
"go.wit.com/gui"
"go.wit.com/lib/gadgets"
"go.wit.com/lib/gui/shell"
"go.wit.com/log"
)
func debug() {
log.Info("cmd line --debugger == true")
func() {
for {
log.Sleep(30)
log.Info("cmd line --debugger == true")
// debugger.DebugWindow()
}
}()
}
func doGui() {
if me.forge.Config.GetDefaultGui() == "" {
me.forge.Config.DefaultGui = "gocui"
me.forge.ConfigSave()
}
me.myGui = gui.New()
me.myGui.InitEmbed(resources)
me.myGui.SetAppDefaultPlugin(me.forge.Config.DefaultGui) // sets the default GUI plugin to use
me.myGui.Default()
mainWindow := gadgets.RawBasicWindow("Forge: (this kinda works sometimes)")
mainWindow.Make()
mainWindow.Show()
mainWindow.Custom = func() {
log.Warn("MAIN WINDOW CLOSE")
now := time.Now()
count := me.forge.RillReload()
log.Info("Repo Reload count =", count)
if count != 0 {
me.forge.ConfigSave()
}
// this is just interesting to see how fast it is on various boxes
// and with how many repos you are working with. On my current laptop
// I have 320 repos and when I'm using it and most things are in memory
// cache, it took: rill repos.Reload() took (2ms)
// which is hard to believe when my ~/go/src is 13G with 424266 files
// nevermind, there must be something wrong with the code right now
log.Printf("rill repos.Reload() took (%s)\n", shell.FormatDuration(time.Since(now)))
os.Exit(0)
}
drawWindow(mainWindow)
// sits here forever
debug()
}
func drawWindow(win *gadgets.BasicWindow) {
var reposWin *repoWindow // this is the handle to the repo window
box := win.Box()
vbox := box.NewVerticalBox("BOX2")
group1 := vbox.NewGroup("Forge Settings")
grid := group1.NewGrid("buildOptions", 0, 0)
// me.autoWorkingPwd = gadgets.NewOneLiner(grid, "working directory (pwd)")
me.goSrcPwd = gadgets.NewOneLiner(grid, "repo src home")
grid.NextRow()
usr, _ := user.Current()
homeDir, err := os.UserHomeDir()
if err != nil {
log.Warn("Error getting home directory:", err)
homeDir = "/home/autotypist"
}
srcDir := filepath.Join(homeDir, "go/src")
me.goSrcPwd.SetText(srcDir)
// use ENV GIT_AUTHOR
me.gitAuthor = gadgets.NewOneLiner(grid, "Git Author")
grid.NextRow()
if os.Getenv("GIT_AUTHOR_NAME") == "" {
me.gitAuthor.SetText("ENV GIT_AUTHOR_NAME is unset")
} else {
author := os.Getenv("GIT_AUTHOR_NAME")
author += " <" + os.Getenv("GIT_AUTHOR_EMAIL") + ">"
me.gitAuthor.SetText(author)
}
// 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
me.setBranchB = grid.NewButton("git checkout", func() {
if reposWin != nil {
reposWin.Hide()
}
targetName := me.newBranch.String()
log.Warn("setting all branches to", targetName)
if targetName == "devel" {
if err := doAllCheckoutDevel(); err != nil {
log.Info("switching to devel branches failed")
}
return
}
if targetName == "master" {
if err := doAllCheckoutMaster(); err != nil {
log.Info("switching to master branches failed")
}
return
}
// just assume user
if err := doAllCheckoutUser(); err != nil {
log.Info("switching to user branches failed")
}
})
me.newBranch = grid.NewDropdown()
me.newBranch.AddText("master")
me.newBranch.AddText("devel")
me.newBranch.AddText(usr.Username)
me.newBranch.SetText(usr.Username)
// checking this will automatically make the branches off of devel
me.autoCreateBranches = grid.NewCheckbox("auto create branches").SetChecked(true)
grid.NextRow()
grid.NewButton("Repo Window", func() {
if reposWin != nil {
if reposWin.Hidden() {
reposWin.Show()
} else {
reposWin.Hide()
}
return
}
reposWin = makeRepoView()
reposWin.Show()
})
var patchWin *patchesWindow
grid.NewButton("Patches Window", func() {
if patchWin != nil {
patchWin.Toggle()
return
}
patchWin = new(patchesWindow)
patchWin.initWindow()
patchWin.Show()
})
grid.NewButton("forge ConfigSave()", func() {
me.forge.ConfigSave()
})
}
|