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
|
package repolist
// does processing on the go.mod and go.sum files
import (
"errors"
"strings"
"go.wit.com/log"
)
// scans through everything in the go.sum file to make
// sure the versions are correct when attempting to do a GUI release
func (rl *RepoList) CheckValidGoSum(r *Repo) (bool, error) {
log.Log(REPOWARN, "CheckValidGoSum() started")
ok, err := r.Status.MakeRedomod()
if !ok {
log.Log(REPOWARN, "CheckValidGoSum() failed", err)
return ok, err
}
// go through each go.sum dependancy to see if the package is released
for depPath, version := range r.Status.GoConfig() {
log.Log(REPO, " ", depPath, version)
// lookup the repo
deprs := rl.FindRepo(depPath)
if deprs == nil {
// well, the go.sum dependancy hasn't been processed or doesn't exist
// so, download it? ignore it?
// for now, if it's not one of the GUI repos, assume it's readonly and ignore it
if strings.HasPrefix(depPath, "go.wit.com") {
log.Log(REPOWARN, "Run: go get -v", depPath)
// rs.RunCmd([]string{"go", "get", "-v", depname}) // download this here?
return false, errors.New("CheckValidGoSum() download repo: " + depPath)
}
// it's probably okay. running a compile check before this would be a good test
continue
}
if deprs.ReadOnly() {
// ignore versioning on other repos. todo: help fix this situation somehow?
continue
}
if deprs.CheckDirty() {
return false, errors.New("CheckValidGoSum() depends on dirty repo " + deprs.GoPath())
}
currentV := deprs.Status.GetCurrentVersion()
targetV := deprs.Status.GetTargetVersion()
if currentV != targetV {
return false, errors.New("CheckValidGoSum() depends on yet unreleased repo " + deprs.GoPath())
}
}
// no dependancies error'd out. It should be ok to release this package
log.Log(REPOWARN, "Releasing this should be ok", r.GoPath())
return true, nil
}
/*
// check if it is safe to remake the go.sum & go.mod files
func (rs *RepoStatus) CheckSafeGoSumRemakeOld() (bool, []string) {
// myGoSumS := rs.goSumStatus.String()
if rs.ReadGoMod() {
log.Log(REPO, "parsed go.mod", rs.realPath.String())
} else {
log.Log(REPOWARN, "Something went wrong parsing go.mod", rs.realPath.String())
return false, nil
}
log.Log(REPOWARN, "go.sum:", rs.realPath.String())
var clean []string
for depname, version := range rs.goConfig {
if strings.HasSuffix(depname, "/v2") {
log.Log(REPOWARN, " FOUND /v2 wierd golang stuff. instead, look for:", depname)
depname = strings.TrimSuffix(depname, "/v2")
}
log.Log(REPOWARN, " ", depname, version)
deprs, ok := windowMap[depname]
if ok {
if deprs.CheckDirty() {
log.Log(REPOWARN, " IS DIRTY", deprs.String())
clean = append(clean, deprs.String())
}
if deprs.readOnly.String() == "true" {
log.Log(REPOWARN, " SKIPPING Read Only", deprs.String())
} else {
// goSumS := deprs.goSumStatus.String()
log.Log(REPOWARN, " FOUND", deprs.String())
username := deprs.mainWorkingName.String()
userhash, _ := deprs.gitConfig.hashes[username]
userversion, _ := deprs.gitConfig.versions[userhash]
log.Log(REPOWARN, " username :"+username, userhash)
log.Log(REPOWARN, " username :"+username, userversion)
if version == userversion {
log.Log(REPOWARN, " USER VERSIONS MATCH", version, userversion)
clean = append(clean, deprs.String())
} else {
os.Unsetenv("GO111MODULE")
log.Log(REPOWARN, " USER VERSIONS MISMATCH", version, userversion)
log.Log(REPOWARN, " IGNORE UNCHANGED REPO. RUNNING 'go get'", depname, userversion)
err, output := rs.RunCmd([]string{"go", "get", depname + "@" + userversion})
log.Log(REPOWARN, " go get", depname, err, output)
}
}
} else {
// log.Log(REPOWARN, " NOT FOUND", depname)
// only fail on our stuff
if strings.HasPrefix(depname, "go.wit.com") {
log.Log(REPOWARN, " go get -v", depname)
// rs.RunCmd([]string{"go", "get", "-v", depname})
return false, clean
}
// log.Log(REPOWARN, " NOT FOUND BUT IGNORING FOR NOW")
}
}
if len(clean) == 0 {
return true, nil
}
return false, clean
}
*/
|