summaryrefslogtreecommitdiff
path: root/main.go
blob: 7b0bef84cdec4eaac0982a244c118703a6def34e (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
package main

// An app to submit patches for the 30 GO GUI repos

import (
	"os"

	"go.wit.com/dev/alexflint/arg"
	"go.wit.com/lib/gadgets"
	"go.wit.com/lib/protobuf/forgepb"
	"go.wit.com/log"

	"go.wit.com/gui"
)

// sent via -ldflags
var VERSION string
var BUILDTIME string

func main() {
	me = new(mainType)
	me.pp = arg.MustParse(&argv)

	// load the ~/.config/forge/ config
	me.forge = forgepb.Init()
	os.Setenv("REPO_WORK_PATH", me.forge.GetGoSrc())

	// processes any --list like options
	// may exit
	list()
	scan()
	repomap()
	os.Exit(0)

	if argv.RedoGoMod {
		repos := me.forge.Repos.SortByGoPath()
		for repos.Scan() {
			repo := repos.Next()
			if !repo.IsValid() {
				log.Printf("%10s %-50s", "old?", repo.GetGoPath())
				continue
			}
			if me.forge.IsReadOnly(repo.GetGoPath()) {
				log.Printf("%10s %-50s", "readonly", repo.GetGoPath())
				continue
			}
			repo.RedoGoMod()
		}
		os.Exit(0)
	}

	me.myGui = gui.New()
	me.myGui.Default()

	me.mainWindow = gadgets.RawBasicWindow("submit & test patchsets")
	me.mainWindow.Make()
	me.mainWindow.Show()
	me.mainbox = me.mainWindow.Box()

	// disable the interface while everything is scanned
	me.Disable()

	vbox2 := me.mainbox.NewVerticalBox("BOX2")
	globalBuildOptions(vbox2)
	me.summary = submitPatchesBox(vbox2)

	me.repos = makeRepoView()

	// processing is done. update the repo summary box
	me.summary.Update()

	me.Enable()

	// intermittently scans the status indefinitly
	me.repos.View.Watchdog(func() {
		log.Info("In main()")
		// processing is done. update the repo summary box
		me.summary.Update()
	})
}