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
|
// This is a simple example
package main
import (
"strings"
"go.wit.com/log"
// "go.wit.com/gui/gui"
// "go.wit.com/gui/gadgets"
// "go.wit.com/apps/control-panel-dns/smartwindow"
)
func (r *repo) checkoutBranch(branch string) {
if r.checkDirty() {
return
}
out := run(r.path, "git", "checkout " + branch)
log.Warn(r.path, "git checkout " + branch, "returned", out)
realname := r.getCurrentBranchName()
realversion := r.getCurrentBranchVersion()
log.Warn(r.path, "realname =", realname, "realversion =", realversion)
if realname == "jcarr" {
r.jcarrVersion.Set(realversion)
}
if realname == "devel" {
r.develVersion.Set(realversion)
}
if realname == "master" {
r.masterVersion.Set(realversion)
}
}
func (r *repo) getBranch() {
out := run(r.path, "git", "branch --show-current")
r.bLabel.SetText(out)
}
func (r *repo) checkDirty() bool {
if r.path == "" {
log.Warn("disable spaceholders")
r.cButton.Disable()
r.pButton.Disable()
return false
}
out := run(r.path, "git", "diff-index HEAD")
if out == "" {
r.dirtyLabel.SetText("")
r.pButton.SetText("scan")
return false
} else {
r.dirtyLabel.SetText("dirty")
r.pButton.SetText("scan")
return true
}
}
func (r *repo) getLastTagVersion() string {
out := run(r.path, "git", "rev-list --tags --max-count=1")
out = strings.TrimSpace(out)
r.lasttagrev = out
lastreal := "describe --tags " + out
// out = run(r.path, "git", "describe --tags c871d5ecf051a7dc4e3a77157cdbc0a457eb9ae1")
out = run(r.path, "git", lastreal)
r.lasttag = out
r.lastLabel.SetText(out)
return out
}
func (r *repo) getCurrentBranchName() string {
out := run(r.path, "git", "branch --show-current")
r.bLabel.SetText(out)
return out
}
func (r *repo) getCurrentBranchVersion() string {
out := run(r.path, "git", "describe --tags")
log.Warn("getCurrentBranchVersion", out)
r.vLabel.SetText(out)
return out
}
func (r *repo) populateTags() {
r.tags = listFiles(fullpath(r.path + "/.git/refs/tags"))
for _, tag := range r.tags {
r.tagsDrop.AddText(tag)
}
// r.tagsDrop.SetText(r.lasttag)
}
func (r *repo) scan() {
r.getLastTagVersion()
r.getCurrentBranchName()
r.getCurrentBranchVersion()
r.populateTags()
if r.checkDirty() {
return
}
r.checkoutBranch("master")
r.checkoutBranch("devel")
r.checkoutBranch("jcarr")
lasttag := r.lastLabel.GetText()
master := r.masterVersion.GetText()
devel := r.develVersion.GetText()
jcarr := r.jcarrVersion.GetText()
log.Warn("")
log.Warn("lasttag =", lasttag)
log.Warn("master =", master)
log.Warn("devel =", devel)
log.Warn("jcarr =", jcarr)
r.dirtyLabel.SetText("garbage")
if devel != master {
log.Warn("devel version != master version", devel, "vs", master)
r.dirtyLabel.SetText("merge")
return
}
if lasttag != master {
log.Warn("last tag rev != master version", lasttag, "vs", master)
r.dirtyLabel.SetText("merge")
return
}
if lasttag == jcarr {
log.Warn("last tag rev == jcarr version", lasttag, "vs", jcarr)
r.dirtyLabel.SetText("GOOD")
return
}
}
func checkrepos() {
for i, r := range allrepos {
log.Warn("scannning", i, r.path)
r.scan()
}
}
|