summaryrefslogtreecommitdiff
path: root/branchesBox.go
blob: d24af80e943d3041c0627a4968c502a02066114c (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
package repostatus

import (
	"go.wit.com/lib/gadgets"
	"go.wit.com/log"
)

func (rs *RepoStatus) makeBranchesBox() {
	rs.gitBranchesGroup = rs.window.Box().NewGroup("branches")
	newgrid := rs.gitBranchesGroup.NewGrid("gridnuts", 0, 0)

	rs.lasttag = gadgets.NewOneLiner(newgrid, "last tag")
	newgrid.NextRow()

	rs.masterBranchVersion = gadgets.NewOneLiner(newgrid, "master")
	newgrid.NextRow()
	rs.develBranchVersion = gadgets.NewOneLiner(newgrid, "devel")
	newgrid.NextRow()
	rs.userBranchVersion = gadgets.NewOneLiner(newgrid, "user")
	newgrid.NextRow()

	rs.currentBranch = gadgets.NewOneLiner(newgrid, "current branch")
	newgrid.NextRow()
	rs.currentVersion = gadgets.NewOneLiner(newgrid, "current version")
	newgrid.NextRow()

	rs.switchBranchB = newgrid.NewButton("Switch Branch", func() {
		bname := rs.targetBranch.String()
		log.Info("Should switch to branch", bname, "here")

		var all [][]string
		all = append(all, []string{"git", "checkout", bname})
		if rs.DoAll(all) {
			log.Info("branch switched to", bname)
		} else {
			log.Info("branch switched to", bname, "failed")
		}
		rs.UpdateCurrent()
	})

	rs.targetBranch = newgrid.NewDropdown()
	// rs.targetBranch.AddText("master")
	newgrid.NextRow()

	rs.showBranchesButton = newgrid.NewButton("scan branches()", func() {
		all := rs.getBranches()
		for i, s := range all {
			log.Log(WARN, "found branch", i, s)
			rs.targetBranch.AddText(s)
		}
		i := len(all)
		log.Log(WARN, "branch count =", i)
	})
	newgrid.NextRow()

	rs.checkBranchesButton = newgrid.NewButton("CheckBranches()", func() {
		if rs.CheckBranches() {
			log.Log(WARN, "Branches are perfect")
		} else {
			log.Log(WARN, "Branches are not perfect")
		}
	})
	newgrid.NextRow()

	newgrid.NewButton("Revert master to devel", func() {
		rs.RevertMasterToDevel()
	})
}