@@ -33,6 +33,10 @@ can be disabled with -skip-lock and -skip-vendor, respectively.
33
33
34
34
(See https://golang.github.io/dep/docs/ensure-mechanics.html#staying-in-sync for
35
35
more information on what it means to be "in sync.")
36
+
37
+ If your workflow necessitates that you modify the contents of vendor, you can
38
+ force check to ignore hash mismatches on a per-project basis by naming
39
+ project roots in Gopkg.toml's "noverify" list.
36
40
`
37
41
38
42
type checkCommand struct {
@@ -132,23 +136,42 @@ func (cmd *checkCommand) Run(ctx *dep.Ctx, args []string) error {
132
136
logger .Println ()
133
137
}
134
138
139
+ noverify := make (map [string ]bool )
140
+ for _ , skip := range p .Manifest .NoVerify {
141
+ noverify [skip ] = true
142
+ }
143
+
135
144
var vendorfail bool
136
145
// One full pass through, to see if we need to print the header, and to
137
146
// create an array of names to sort for deterministic output.
138
147
var ordered []string
139
148
for path , status := range statuses {
140
149
ordered = append (ordered , path )
141
- if status != verify .NoMismatch {
150
+
151
+ switch status {
152
+ case verify .DigestMismatchInLock , verify .HashVersionMismatch , verify .EmptyDigestInLock :
153
+ // NoVerify applies only to these three cases.
154
+ if noverify [path ] {
155
+ continue
156
+ }
157
+ fallthrough
158
+ case verify .NotInTree , verify .NotInLock :
142
159
fail = true
143
160
if ! vendorfail {
144
161
vendorfail = true
145
162
logger .Println ("# vendor is out of sync:" )
146
163
}
164
+
147
165
}
148
166
}
149
167
sort .Strings (ordered )
150
168
151
169
for _ , pr := range ordered {
170
+ var nvSuffix string
171
+ if noverify [pr ] {
172
+ nvSuffix = " (CHECK IGNORED: marked noverify in Gopkg.toml)"
173
+ }
174
+
152
175
status := statuses [pr ]
153
176
switch status {
154
177
case verify .NotInTree :
@@ -158,19 +181,20 @@ func (cmd *checkCommand) Run(ctx *dep.Ctx, args []string) error {
158
181
if err != nil {
159
182
return errors .Wrap (err , "could not stat file that VerifyVendor claimed existed" )
160
183
}
161
-
162
184
if fi .IsDir () {
163
185
logger .Printf ("%s: unused project\n " , pr )
164
186
} else {
165
187
logger .Printf ("%s: orphaned file\n " , pr )
166
188
}
167
189
case verify .DigestMismatchInLock :
168
- logger .Printf ("%s: hash of vendored tree didn't match digest in Gopkg.lock\n " , pr )
190
+ logger .Printf ("%s: hash of vendored tree not equal to digest in Gopkg.lock%s\n " , pr , nvSuffix )
191
+ case verify .EmptyDigestInLock :
192
+ logger .Printf ("%s: no digest in Gopkg.lock to compare against hash of vendored tree%s\n " , pr , nvSuffix )
169
193
case verify .HashVersionMismatch :
170
194
// This will double-print if the hash version is zero, but
171
195
// that's a rare case that really only occurs before the first
172
196
// run with a version of dep >=0.5.0, so it's fine.
173
- logger .Printf ("%s: hash algorithm mismatch, want version %v\n " , pr , verify .HashVersion )
197
+ logger .Printf ("%s: hash algorithm mismatch, want version %v%s \n " , pr , verify .HashVersion , nvSuffix )
174
198
}
175
199
}
176
200
}
@@ -185,12 +209,12 @@ func sprintLockUnsat(lsat verify.LockSatisfaction) string {
185
209
var buf bytes.Buffer
186
210
sort .Strings (lsat .MissingImports )
187
211
for _ , missing := range lsat .MissingImports {
188
- fmt .Fprintf (& buf , "%s: missing from input-imports\n " , missing )
212
+ fmt .Fprintf (& buf , "%s: imported or required, but missing from Gopkg.lock's input-imports\n " , missing )
189
213
}
190
214
191
215
sort .Strings (lsat .ExcessImports )
192
216
for _ , excess := range lsat .ExcessImports {
193
- fmt .Fprintf (& buf , "%s: in input-imports, but not imported\n " , excess )
217
+ fmt .Fprintf (& buf , "%s: in Gopkg.lock's input-imports, but neither imported nor required \n " , excess )
194
218
}
195
219
196
220
var ordered []string
0 commit comments