summaryrefslogtreecommitdiff
path: root/globalDisplayOptions.go
blob: 4ec5c93335bf8fecccb61486f7a9277e95d5b8ce (plain)
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
package main

import (
	"os"
	"strings"

	"go.wit.com/gui"
	"go.wit.com/lib/debugger"
	"go.wit.com/lib/gui/logsettings"
	"go.wit.com/log"
)

func globalDisplayOptions(box *gui.Node) {
	vbox := box.NewVerticalBox("DISPLAYVBOX")

	group1 := vbox.NewGroup("Global Display Options")

	hidegrid := group1.NewGrid("hidecfg", 0, 0)

	hidegrid.NewButton("Show Repository Window", func() {
		if me.repos.Hidden() {
			me.repos.Show()
		} else {
			me.repos.Hide()
		}
		log.Info("showing reposwin")
	})
	hidegrid.NextRow()

	me.autoHideReadOnly = hidegrid.NewCheckbox("Hide read-only repos").SetChecked(true)
	me.autoHideReadOnly.Custom = func() {
		if me.autoHideReadOnly.Checked() {
			os.Setenv("AUTOTYPIST_READONLY", "hide")
		} else {
			os.Unsetenv("AUTOTYPIST_READONLY")
		}
	}
	os.Setenv("AUTOTYPIST_READONLY", "hide")
	hidegrid.NextRow()

	me.autoHideReleased = hidegrid.NewCheckbox("Hide Released repos").SetChecked(true)
	hidegrid.NextRow()

	me.ignoreWhitelist = hidegrid.NewCheckbox("ignore whitelist (are you sure?)").SetChecked(false)
	hidegrid.NextRow()

	me.scanEveryMinute = hidegrid.NewCheckbox("Scan every minute").SetChecked(false)
	me.scanEveryMinute.Custom = func() {
		if me.scanEveryMinute.Checked() {
			os.Setenv("REPO_AUTO_SCAN", "true")
			log.Info("env REPO_AUTO_SCAN=", os.Getenv("REPO_AUTO_SCAN"))
		} else {
			os.Unsetenv("REPO_AUTO_SCAN")
			log.Info("env REPO_AUTO_SCAN=", os.Getenv("REPO_AUTO_SCAN"))
		}
	}

	hidegrid.NewButton("scan now", func() {
		log.Info("re-scanning repos now")
		i, s := me.repos.View.ScanRepositories()
		log.Info("re-scanning repos done", i, s)
		// me.duration.SetText(s)
	})
	me.duration = me.repos.View.MirrorScanDuration()
	hidegrid.Append(me.duration)

	hidegrid.NextRow()

	group1 = vbox.NewGroup("prep for release")
	grid := group1.RawGrid()

	var longB *gui.Node
	longB = grid.NewButton("generate go.sum files", func() {
		me.Disable()
		var worked bool = true
		for _, repo := range me.repos.View.AllRepos() {
			if whitelist(repo.GoPath()) {
				continue
			}
			ok, err := me.repos.View.CheckValidGoSum(repo)
			if !ok {
				log.Info("redo go.sum failed on", repo.GoPath(), err)
				worked = false
			}
		}
		log.Info("redo go.sum finished with", worked)
		me.Enable()
		longB.SetLabel("go.sum files created")
		if worked {
			longB.Disable()
		}
	})

	me.setBranchesToMasterB = grid.NewButton("set all branches to master", func() {
		me.Disable()
		defer me.Enable()
		if setAllBranchesToMaster() {
			// if it succeeds, disable this button
			me.setBranchesToMasterB.Disable()
		}
	})
	grid.NextRow()

	var incrementTags *gui.Node
	incrementTags = grid.NewButton("increment tags", func() {
		me.Disable()
		for _, repo := range me.repos.View.AllRepos() {
			if whitelist(repo.GoPath()) {
				continue
			}
			if repo.ReadOnly() {
				continue
			}
			lasttag := repo.LastTag()
			masterv := repo.Status.GetMasterVersion()
			targetv := repo.Status.GetTargetVersion()

			if lasttag == masterv {
				// nothing to do if curv == masterv
				// unless go.sum depends on changed repos
				if targetv != lasttag {
					log.Info(repo.GoPath(), "trigger a new release?", targetv, lasttag)
					// repo.Status.SetVersion("0", "21", "0", me.releaseReasonS)
					repo.Status.IncrementMinorVersion(me.releaseReasonS)
				}

				continue
			}

			newversion := repo.Status.GetNewVersionTag()
			if newversion == targetv {
				log.Info(repo.GoPath(), "targetv has been increased already to", targetv)
				continue
			}

			if masterv != targetv {
				log.Info(repo.GoPath(), "master and target differ", masterv, targetv)
				repo.Status.IncrementVersion()
				newversion := repo.Status.GetNewVersionTag()
				repo.Status.SetTargetVersion("v" + newversion)
				// already incremented
				continue
			}
		}
		if findNext() {
			log.Info("findNext() found a repo")
		}
		incrementTags.SetText("maybe ready?")
		me.Enable()
	})
	grid.NewButton("increment minor version", func() {
		// this is messy still. if the release process fails, it needs to continue
		// for now, use the "go.wit.com/log" release minor number as the official
		// release. If it hasn't been updated yet, then start there
		logrepo := me.repos.View.FindRepo("go.wit.com/log")
		if logrepo == nil {
			log.Info("couldn't find go.wit.com/log")
			return
		}
		releasev := logrepo.Status.LastTag()
		for _, repo := range me.repos.View.AllRepos() {
			if whitelist(repo.GoPath()) {
				continue
			}
			if repo.ReadOnly() {
				continue
			}
			if strings.HasPrefix(repo.GoPath(), "go.wit.com/dev") {
				continue
			}
			if strings.HasPrefix(repo.GoPath(), "go.wit.com/widget") {
				// widget I versioned early before I knew what the hell this would mean and can
				// not be down versioned because that's not how GO versioning works. Once you
				// set the version for a path, it's set in stone forever. (smart system!)
				// we could rename go.wit.com/widget to go.wit.com/newwidget and restart the versioning
				// system, but that's rediculous and this servers to always remind me to never make this mistake again
				repo.Status.IncrementRevisionVersion("trying minor")
				continue
			}
			if releasev == repo.Status.LastTag() {
				log.Info("skipping already released repo", repo.Status.GoPath())
				repo.Status.SetTargetVersion(releasev)
				continue
			}
			// repo.Status.SetVersion("0", "22", "0", "trying increment minor")
			repo.Status.IncrementMinorVersion("trying minor")
		}
	})
	grid.NextRow()

	group2 := vbox.NewGroup("Debugger")
	dbggrid := group2.NewGrid("gdb", 0, 0)
	dbggrid.NewButton("logging Window", func() {
		logsettings.LogWindow()
	})
	dbggrid.NextRow()

	dbggrid.NewButton("Debugger Window", func() {
		debugger.DebugWindow()
	})
}

func hidePerfect() {
	for _, repo := range me.repos.View.AllRepos() {
		if repo.State() == "PERFECT" {
			if repo.Hidden() {
				continue
			}
			repo.Hide()
			// return
		}
	}
}