Skip to content
This repository was archived by the owner on Sep 9, 2020. It is now read-only.

Commit 3d0cccb

Browse files
committed
Merge branch 'master' into unit_tests
2 parents 579f492 + 73b3afe commit 3d0cccb

File tree

36 files changed

+336
-100
lines changed

36 files changed

+336
-100
lines changed

.codeclimate.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ checks:
2222
enabled: false
2323
plugins:
2424
gofmt:
25-
enabled: true
25+
# Codeclimate go fmt does not agree with tip go fmt; consider re-enabling
26+
# CC when the advice matches up with tip again.
27+
enabled: false
2628
govet:
2729
enabled: true
2830
golint:

.travis.yml

+26-6
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,61 @@
11
language: go
22
sudo: false
3+
dist: xenial
34
notifications:
45
email: false
56
jobs:
67
include:
78
- stage: test
89
go_import_path: github.com/golang/dep
910
install:
11+
- ssh-keyscan -t $TRAVIS_SSH_KEY_TYPES -H bitbucket.org >> ~/.ssh/known_hosts
1012
- make get-deps
1113
- npm install -g codeclimate-test-reporter
1214
env:
1315
- DEPTESTBYPASS501=1
16+
- TZ=UTC
1417
os: linux
15-
go: 1.10.x
18+
go: 1.11.x
1619
script:
1720
- make validate test
1821
- ./hack/coverage.bash
1922
after_success:
2023
- codeclimate-test-reporter < coverage.txt
2124
# YAML alias, for settings shared across the simpler builds
2225
- &simple-test
23-
go: 1.9.x
26+
go: 1.10.x
2427
stage: test
2528
go_import_path: github.com/golang/dep
26-
install: skip
29+
install:
30+
- ssh-keyscan -t $TRAVIS_SSH_KEY_TYPES -H bitbucket.org >> ~/.ssh/known_hosts
2731
env:
2832
- DEPTESTBYPASS501=1
33+
- TZ=UTC
2934
script: make test
35+
- <<: *simple-test
36+
go: 1.9.x
3037
- <<: *simple-test
3138
go: tip
39+
install:
40+
- ssh-keyscan -t $TRAVIS_SSH_KEY_TYPES -H bitbucket.org >> ~/.ssh/known_hosts
41+
- mkdir -p /home/travis/var/cache
42+
env:
43+
- GOCACHE=/home/travis/var/cache
44+
- DEPTESTBYPASS501=1
45+
- TZ=UTC
46+
3247
- <<: *simple-test
3348
os: osx
34-
go: 1.10.x
49+
go: 1.11.x
3550
install:
3651
# brew takes horribly long to update itself despite the above caching
3752
# attempt; only bzr install if it's not on the $PATH
53+
- ssh-keyscan -t $TRAVIS_SSH_KEY_TYPES -H bitbucket.org >> ~/.ssh/known_hosts
3854
- test $(which bzr) || brew install bzr
3955
env:
4056
- HOMEBREW_NO_AUTO_UPDATE=1
4157
- DEPTESTBYPASS501=1
58+
- TZ=UTC
4259
script:
4360
# OSX as of El Capitan sets an exit trap that interacts poorly with how
4461
# travis seems to spawn these shells; if set -e is set, then it can cause
@@ -47,13 +64,14 @@ jobs:
4764
# Related: https://superuser.com/questions/1044130/why-am-i-having-how-can-i-fix-this-error-shell-session-update-command-not-f
4865
- trap EXIT
4966
- make test
50-
- go: 1.10.x
67+
- go: 1.11.x
5168
# Run on OS X so that we get a CGO-enabled binary for this OS; see
5269
# https://github.com/golang/dep/issues/1838 for more details.
5370
os: osx
5471
stage: deploy
5572
go_import_path: github.com/golang/dep
56-
install: skip
73+
install:
74+
- ssh-keyscan -t $TRAVIS_SSH_KEY_TYPES -H bitbucket.org >> ~/.ssh/known_hosts
5775
script: skip
5876
before_deploy:
5977
- ./hack/build-all.bash
@@ -82,6 +100,8 @@ jobs:
82100
- release/dep-linux-ppc64.sha256
83101
- release/dep-linux-ppc64le
84102
- release/dep-linux-ppc64le.sha256
103+
- release/dep-linux-s390x
104+
- release/dep-linux-s390x.sha256
85105
skip_cleanup: true
86106
on:
87107
repo: golang/dep

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# v0.5.1
22

3+
IMPROVEMENTS:
4+
5+
* The `noverify` field in `Gopkg.toml` allows for the preservation of excess files under `vendor`. ([#2002](https://github.com/golang/dep/issue/2002))
6+
37
BUG FIXES:
48

59
* Correctly handle certain cases where `dep ensure` removed projects from Gopkg.lock. ([#1945](https://github.com/golang/dep/issue/1945)).

Gopkg.lock

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/dep/check.go

+35-14
Original file line numberDiff line numberDiff line change
@@ -141,62 +141,83 @@ func (cmd *checkCommand) Run(ctx *dep.Ctx, args []string) error {
141141
noverify[skip] = true
142142
}
143143

144-
var vendorfail bool
144+
var vendorfail, hasnoverify bool
145145
// One full pass through, to see if we need to print the header, and to
146146
// create an array of names to sort for deterministic output.
147147
var ordered []string
148148
for path, status := range statuses {
149149
ordered = append(ordered, path)
150150

151151
switch status {
152-
case verify.DigestMismatchInLock, verify.HashVersionMismatch, verify.EmptyDigestInLock:
153-
// NoVerify applies only to these three cases.
152+
case verify.DigestMismatchInLock, verify.HashVersionMismatch, verify.EmptyDigestInLock, verify.NotInLock:
154153
if noverify[path] {
154+
hasnoverify = true
155155
continue
156156
}
157157
fallthrough
158-
case verify.NotInTree, verify.NotInLock:
158+
case verify.NotInTree:
159+
// NoVerify cannot be used to make dep check ignore the absence
160+
// of a project entirely.
161+
if noverify[path] {
162+
delete(noverify, path)
163+
}
164+
159165
fail = true
160166
if !vendorfail {
161167
vendorfail = true
162-
logger.Println("# vendor is out of sync:")
163168
}
164-
165169
}
166170
}
167171
sort.Strings(ordered)
168172

173+
var vfbuf, novbuf bytes.Buffer
174+
var bufptr *bytes.Buffer
175+
176+
fmt.Fprintf(&vfbuf, "# vendor is out of sync:\n")
177+
fmt.Fprintf(&novbuf, "# out of sync, but ignored, due to noverify in Gopkg.toml:\n")
178+
169179
for _, pr := range ordered {
170-
var nvSuffix string
171180
if noverify[pr] {
172-
nvSuffix = " (CHECK IGNORED: marked noverify in Gopkg.toml)"
181+
bufptr = &novbuf
182+
} else {
183+
bufptr = &vfbuf
173184
}
174185

175186
status := statuses[pr]
176187
switch status {
177188
case verify.NotInTree:
178-
logger.Printf("%s: missing from vendor\n", pr)
189+
fmt.Fprintf(bufptr, "%s: missing from vendor\n", pr)
179190
case verify.NotInLock:
180191
fi, err := os.Stat(filepath.Join(p.AbsRoot, "vendor", pr))
181192
if err != nil {
182193
return errors.Wrap(err, "could not stat file that VerifyVendor claimed existed")
183194
}
184195
if fi.IsDir() {
185-
logger.Printf("%s: unused project\n", pr)
196+
fmt.Fprintf(bufptr, "%s: unused project\n", pr)
186197
} else {
187-
logger.Printf("%s: orphaned file\n", pr)
198+
fmt.Fprintf(bufptr, "%s: orphaned file\n", pr)
188199
}
189200
case verify.DigestMismatchInLock:
190-
logger.Printf("%s: hash of vendored tree not equal to digest in Gopkg.lock%s\n", pr, nvSuffix)
201+
fmt.Fprintf(bufptr, "%s: hash of vendored tree not equal to digest in Gopkg.lock\n", pr)
191202
case verify.EmptyDigestInLock:
192-
logger.Printf("%s: no digest in Gopkg.lock to compare against hash of vendored tree%s\n", pr, nvSuffix)
203+
fmt.Fprintf(bufptr, "%s: no digest in Gopkg.lock to compare against hash of vendored tree\n", pr)
193204
case verify.HashVersionMismatch:
194205
// This will double-print if the hash version is zero, but
195206
// that's a rare case that really only occurs before the first
196207
// run with a version of dep >=0.5.0, so it's fine.
197-
logger.Printf("%s: hash algorithm mismatch, want version %v%s\n", pr, verify.HashVersion, nvSuffix)
208+
fmt.Fprintf(bufptr, "%s: hash algorithm mismatch, want version %v\n", pr, verify.HashVersion)
198209
}
199210
}
211+
212+
if vendorfail {
213+
logger.Print(vfbuf.String())
214+
if hasnoverify {
215+
logger.Println()
216+
}
217+
}
218+
if hasnoverify {
219+
logger.Print(novbuf.String())
220+
}
200221
}
201222

202223
if fail {

cmd/dep/dep_test.go

-4
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,6 @@ func TestMain(m *testing.M) {
3535
os.Setenv("CCACHE_DIR", filepath.Join(home, ".ccache"))
3636
}
3737
os.Setenv("HOME", "/test-dep-home-does-not-exist")
38-
if os.Getenv("GOCACHE") == "" {
39-
os.Setenv("GOCACHE", "off") // because $HOME is gone
40-
}
41-
4238
r := m.Run()
4339

4440
os.Remove("testdep" + test.ExeSuffix)

cmd/dep/init.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func (cmd *initCommand) Run(ctx *dep.Ctx, args []string) error {
7474
}
7575

7676
var root string
77-
if len(args) <= 0 {
77+
if len(args) == 0 {
7878
root = ctx.WorkingDir
7979
} else {
8080
root = args[0]

cmd/dep/status.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ func (out *dotOutput) BasicHeader() error {
340340

341341
func (out *dotOutput) BasicFooter() error {
342342
gvo := out.g.output("")
343-
_, err := fmt.Fprintf(out.w, gvo.String())
343+
_, err := fmt.Fprint(out.w, gvo.String())
344344
return err
345345
}
346346

cmd/dep/status_test.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package main
77
import (
88
"bytes"
99
"fmt"
10+
"io"
1011
"io/ioutil"
1112
"log"
1213
"path/filepath"
@@ -16,8 +17,6 @@ import (
1617
"text/tabwriter"
1718
"text/template"
1819

19-
"io"
20-
2120
"github.com/golang/dep"
2221
"github.com/golang/dep/gps"
2322
"github.com/golang/dep/internal/test"
@@ -28,7 +27,7 @@ func TestStatusFormatVersion(t *testing.T) {
2827
t.Parallel()
2928

3029
tests := map[gps.Version]string{
31-
nil: "",
30+
nil: "",
3231
gps.NewBranch("master"): "branch master",
3332
gps.NewVersion("1.0.0"): "1.0.0",
3433
gps.Revision("flooboofoobooo"): "flooboo",
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
github.com/sdboyer/deptest: hash of vendored tree not equal to digest in Gopkg.lock (CHECK IGNORED: marked noverify in Gopkg.toml)
1+
# out of sync, but ignored, due to noverify in Gopkg.toml:
2+
github.com/sdboyer/deptest: hash of vendored tree not equal to digest in Gopkg.lock
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
github.com/sdboyer/deptest: hash algorithm mismatch, want version 1 (CHECK IGNORED: marked noverify in Gopkg.toml)
1+
# out of sync, but ignored, due to noverify in Gopkg.toml:
2+
github.com/sdboyer/deptest: hash algorithm mismatch, want version 1

cmd/dep/testdata/harness_tests/ensure/noverify/hash_mismatch/README

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ This is a hack - it's effectively just verifying that the Gopkg.lock doesn't
22
change for projects with noverify set, which (under the current logic) is an
33
indicator that vendor wasn't updated.
44

5-
Of course, that vendor -> lock relatinoship isn't guaranteed to hold...
5+
Of course, that vendor -> lock relationship isn't guaranteed to hold...

cmd/dep/testdata/harness_tests/ensure/noverify/vendororphans/final/Gopkg.lock

+17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
noverify = ["foo", "orphdir"]

cmd/dep/testdata/harness_tests/ensure/noverify/vendororphans/initial/Gopkg.lock

+17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
noverify = ["foo", "orphdir"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright 2017 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
package main
6+
7+
import (
8+
_ "github.com/sdboyer/deptest"
9+
)
10+
11+
func main() {
12+
}

cmd/dep/testdata/harness_tests/ensure/noverify/vendororphans/initial/vendor/foo

Whitespace-only changes.

cmd/dep/testdata/harness_tests/ensure/noverify/vendororphans/initial/vendor/github.com/sdboyer/deptest/deptest.go

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/dep/testdata/harness_tests/ensure/noverify/vendororphans/initial/vendor/orphdir/.gitkeep

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# out of sync, but ignored, due to noverify in Gopkg.toml:
2+
foo: orphaned file
3+
orphdir: unused project
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"commands": [
3+
["ensure"],
4+
["check"]
5+
],
6+
"vendor-final": [
7+
"github.com/sdboyer/deptest"
8+
]
9+
}

docs/Gopkg.toml.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -231,18 +231,20 @@ It is usually safe to set `non-go = true`, as well. However, as dep only has a c
231231

232232
## `noverify`
233233

234-
The `noverify` field is a list of [project roots](glossary.md#project-root) to exclude from [vendor verification](glossary.md#vendor-verification).
234+
The `noverify` field is a list of paths, typically [project roots](glossary.md#project-root), to exclude from [vendor verification](glossary.md#vendor-verification).
235235

236236
Dep uses per-project hash digests, computed after pruning and recorded in [Gopkg.lock](Gopkg.lock.md#digest), to determine if the contents of `vendor/` are as expected. If the recorded digest and the hash of the corresponding tree in `vendor/` differ, that project is considered to be out of sync:
237237

238238
* `dep ensure` will regenerate it
239239
* `dep check` will complain of a hash mismatch and exit 1
240240

241-
It is strongly preferable for almost all workflows that you leave `vendor/` unmodified, in whatever state dep puts it in. However, this isn't always an option. If you have no choice but to modify `vendor/` for a particular project, then add the project root for that project to `noverify`. This will have the following effects:
241+
It is strongly recommended that you leave `vendor/` unmodified, in whatever state dep puts it in. However, this isn't always feasible. If you have no choice but to modify `vendor/` for a particular project, then add the project root for that project to `noverify`. This will have the following effects:
242242

243243
* `dep ensure` will ignore hash mismatches for the project, and only regenerate it in `vendor/` if absolutely necessary (prune options change, package list changes, version changes)
244244
* `dep check` will continue to report hash mismatches (albeit with an annotation about `noverify`) for the project, but will no longer exit 1.
245245

246+
`noverify` can also be used to preserve certain excess paths that would otherwise be removed; for example, adding `WORKSPACE` to the `noverify` list would allow you to preserve `vendor/WORKSPACE`, which can help with some Bazel-based workflows.
247+
246248
## Scope
247249

248250
`dep` evaluates

docs/ensure-mechanics.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Briefly, the four states are:
1313
1. The [current project's](glossary.md#current-project) source code.
1414
2. A [manifest](glossary.md#manifest) - a file describing the current project's dependency requirements. In dep, this is the [`Gopkg.toml`](Gopkg.toml.md) file.
1515
3. A [lock](glossary.md#lock) - a file containing a transitively-complete, reproducible description of the dependency graph. In dep, this is the [`Gopkg.lock`](Gopkg.lock.md) file.
16-
4. The source code of the dependences themselves. In dep's current design, this is the `vendor/` directory.
16+
4. The source code of the dependencies themselves. In dep's current design, this is the `vendor/` directory.
1717

1818
We can visually represent these four states as follows:
1919

@@ -156,7 +156,7 @@ Ordinarily, when the solver encounters a project name for which there's an entry
156156

157157
"Skips pulling the version from the lock" would imply that `dep ensure -update github.com/foo/bar` is equivalent to removing the `[[project]]` stanza for `github.com/foo/bar` from your `Gopkg.lock`, then running `dep ensure`. And indeed it is - however, that approach is not recommended, and subtle changes may be introduced in the future that complicate the equivalency.
158158

159-
If `-update` is passed with no arguments, then `ChangeAll` is set to `true`, resulting in the solver ignoring `Gopkg.lock` for all newly-encountered project names. This is equivalent to explicitly passing all of your dependences as arguments to `dep ensure -update`, as well as `rm Gopkg.lock && dep ensure`. Again, however, neither of these approaches are recommended, and future changes may introduce subtle differences.
159+
If `-update` is passed with no arguments, then `ChangeAll` is set to `true`, resulting in the solver ignoring `Gopkg.lock` for all newly-encountered project names. This is equivalent to explicitly passing all of your dependencies as arguments to `dep ensure -update`, as well as `rm Gopkg.lock && dep ensure`. Again, however, neither of these approaches are recommended, and future changes may introduce subtle differences.
160160

161161
When a version hint from `Gopkg.lock` is not placed at the head of the version queue, it means that dep will explore the set of possible versions for a particular dependency. This exploration is performed according to a [fixed sort order](https://godoc.org/github.com/golang/dep/gps#SortForUpgrade), where newer versions are tried first, resulting in an update.
162162

0 commit comments

Comments
 (0)