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
|
package forgepb
import (
"errors"
"fmt"
"strings"
"go.wit.com/lib/env"
"go.wit.com/lib/protobuf/gitpb"
"go.wit.com/log"
)
// DOES NOT MODIFY ANYTHING
//
// this is a final check to make sure, before pushing
// a golang repo, that the go.sum file has the correct
// and current version of every package
//
// it re-scans the go.sum file. DOES NOT MODIFY ANYTHING
// this is the last thing to run to double check everything
// before 'git tag' or git push --tags
func (f *Forge) FinalGoDepsCheckOk(check *gitpb.Repo) error {
if check == nil {
return errors.New("FinalGoDepsCheckOk() boo, check == nil")
}
// parse the go.mod and go.sum files
if !check.ParseGoSum() {
return fmt.Errorf("forge.ParseGoSum() failed. go.mod & go.sum are broken")
}
if check.GetGoPrimitive() {
return nil
}
deps := check.GoInfo.GoDeps.SortByGoPath()
for deps.Scan() {
depRepo := deps.Next()
found := f.Repos.FindByNamespace(depRepo.GetGoPath())
if found == nil {
if f.CheckOverride(depRepo.GetGoPath()) {
// skip this gopath because it's probably broken forever
continue
}
return fmt.Errorf("dep not found: %s", depRepo.GetGoPath())
}
if depRepo.GetVersion() == found.GetMasterVersion() {
// log.Printf("%-48s error ?? %-10s vs %-10s\n", depRepo.GetGoPath(), depRepo.GetVersion(), found.GetMasterVersion())
continue
}
// log.Info("found dep", depRepo.GetGoPath())
if depRepo.GetVersion() != found.GetTargetVersion() {
check := f.Repos.FindByNamespace(depRepo.GetGoPath())
if f.Config.IsReadOnly(check.GetGoPath()) {
if env.Verbose() {
log.Printf("%-48s ok error .%s. vs .%s. (ignoring read-only repo)\n", depRepo.GetGoPath(), depRepo.GetVersion(), found.GetTargetVersion())
}
} else {
if f.CheckOverride(depRepo.GetGoPath()) {
if env.Verbose() {
log.Printf("%-48s ok error .%s. vs .%s. (forge.CheckOverride())\n", depRepo.GetGoPath(), depRepo.GetVersion(), found.GetTargetVersion())
}
// skip this gopath because it's probably broken forever
continue
} else {
// log.Printf("%-48s error ?? %-10s vs %-10s\n", depRepo.GetGoPath(), depRepo.GetVersion(), found.GetMasterVersion())
// log.Printf("%-48s error %10s vs %10s\n", depRepo.GetGoPath(), depRepo.GetVersion(), found.GetTargetVersion())
return fmt.Errorf("%-48s error %10s vs %10s", depRepo.GetGoPath(), depRepo.GetVersion(), found.GetMasterVersion())
}
}
}
}
return nil
}
// TODO: this is a dumb hack & needs to be updated to talk to forged
func (f *Forge) CheckOverride(gopath string) bool {
if gopath == "bou.ke/monkey" {
// log.Info("CheckOverride() is bypassing", gopath)
return true
}
if gopath == "github.com/posener/complete/v2" {
// log.Info("CheckOverride() is bypassing", gopath)
return true
}
if strings.HasPrefix(gopath, "github.com/go-gl") {
// log.Info("CheckOverride() is bypassing", gopath)
return true
}
if strings.HasPrefix(gopath, "google.golang.org") {
// log.Info("CheckOverride() is bypassing", gopath)
return true
}
if strings.HasPrefix(gopath, "cloud.google.com/go") {
// log.Info("CheckOverride() is bypassing", gopath)
return true
}
if strings.HasPrefix(gopath, "go.opencensus.io") {
// log.Info("CheckOverride() is bypassing", gopath)
return true
}
if strings.HasPrefix(gopath, "github.com/nicksnyder/go-i18n") {
// log.Info("CheckOverride() is bypassing", gopath)
return true
}
// fuckit for now. just blacklist github.com
if strings.HasPrefix(gopath, "github.com/") {
if env.Verbose() {
// log.Info("CheckOverride() is ignoring everything at github.com", gopath)
}
return true
}
if !strings.HasPrefix(gopath, "go.wit.com") {
// log.Info("CheckOverride() is ignoring else not at go.wit.com", gopath)
return true
}
return false
}
// checks to see if the any of the go dependancies are packages
// that need to be upgraded. If found, returns that conflict namespace
func (f *Forge) CheckUpdatingGoDeps(godeps *gitpb.GoDeps, upgrading *gitpb.Repos) error {
if godeps == nil {
return errors.New("forge.CheckUpdatingGoDeps() godeps == nil")
}
all := godeps.SortByGoPath()
for all.Scan() {
depRepo := all.Next()
found := upgrading.FindByNamespace(depRepo.GetGoPath())
if found != nil {
return fmt.Errorf("waiting on %s", depRepo.GetGoPath())
}
}
return nil
}
func (f *Forge) TestGoDepsCheckOk(godeps *gitpb.GoDeps) error {
if godeps == nil {
return errors.New("forge.TestGoDepsCheckOk() godeps == nil")
}
all := godeps.SortByGoPath()
for all.Scan() {
depRepo := all.Next()
found := f.Repos.FindByNamespace(depRepo.GetGoPath())
if found == nil {
if f.CheckOverride(depRepo.GetGoPath()) {
// skip this gopath because it's probably broken forever
continue
}
return fmt.Errorf("dep not found: %s", depRepo.GetGoPath())
}
if depRepo.GetVersion() == found.GetMasterVersion() {
// log.Printf("%-48s error ?? %-10s vs %-10s\n", depRepo.GetGoPath(), depRepo.GetVersion(), found.GetMasterVersion())
continue
}
// log.Info("found dep", depRepo.GetGoPath())
if depRepo.GetVersion() != found.GetTargetVersion() {
check := f.Repos.FindByNamespace(depRepo.GetGoPath())
if f.Config.IsReadOnly(check.GetGoPath()) {
if env.Verbose() {
log.Printf("%-48s ok error .%s. vs .%s. (ignoring read-only repo)\n", depRepo.GetGoPath(), depRepo.GetVersion(), found.GetTargetVersion())
}
} else {
if f.CheckOverride(depRepo.GetGoPath()) {
if env.Verbose() {
log.Printf("%-48s ok error .%s. vs .%s. (forge.CheckOverride())\n", depRepo.GetGoPath(), depRepo.GetVersion(), found.GetTargetVersion())
}
// skip this gopath because it's probably broken forever
continue
} else {
// log.Printf("%-48s error ?? %-10s vs %-10s\n", depRepo.GetGoPath(), depRepo.GetVersion(), found.GetMasterVersion())
// log.Printf("%-48s error %10s vs %10s\n", depRepo.GetGoPath(), depRepo.GetVersion(), found.GetTargetVersion())
return fmt.Errorf("%-48s error %10s vs %10s", depRepo.GetGoPath(), depRepo.GetVersion(), found.GetMasterVersion())
}
}
}
}
return nil
}
|