Skip to content
This repository was archived by the owner on Sep 9, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 30 additions & 6 deletions cmd/dep/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ can be disabled with -skip-lock and -skip-vendor, respectively.

(See https://golang.github.io/dep/docs/ensure-mechanics.html#staying-in-sync for
more information on what it means to be "in sync.")

If your workflow necessitates that you modify the contents of vendor, you can
force check to ignore hash mismatches on a per-project basis by naming
project roots in Gopkg.toml's "noverify" list.
`

type checkCommand struct {
Expand Down Expand Up @@ -132,23 +136,42 @@ func (cmd *checkCommand) Run(ctx *dep.Ctx, args []string) error {
logger.Println()
}

noverify := make(map[string]bool)
for _, skip := range p.Manifest.NoVerify {
noverify[skip] = true
}

var vendorfail bool
// One full pass through, to see if we need to print the header, and to
// create an array of names to sort for deterministic output.
var ordered []string
for path, status := range statuses {
ordered = append(ordered, path)
if status != verify.NoMismatch {

switch status {
case verify.DigestMismatchInLock, verify.HashVersionMismatch, verify.EmptyDigestInLock:
// NoVerify applies only to these three cases.
if noverify[path] {
continue
}
fallthrough
case verify.NotInTree, verify.NotInLock:
fail = true
if !vendorfail {
vendorfail = true
logger.Println("# vendor is out of sync:")
}

}
}
sort.Strings(ordered)

for _, pr := range ordered {
var nvSuffix string
if noverify[pr] {
nvSuffix = " (CHECK IGNORED: marked noverify in Gopkg.toml)"
}

status := statuses[pr]
switch status {
case verify.NotInTree:
Expand All @@ -158,19 +181,20 @@ func (cmd *checkCommand) Run(ctx *dep.Ctx, args []string) error {
if err != nil {
return errors.Wrap(err, "could not stat file that VerifyVendor claimed existed")
}

if fi.IsDir() {
logger.Printf("%s: unused project\n", pr)
} else {
logger.Printf("%s: orphaned file\n", pr)
}
case verify.DigestMismatchInLock:
logger.Printf("%s: hash of vendored tree didn't match digest in Gopkg.lock\n", pr)
logger.Printf("%s: hash of vendored tree not equal to digest in Gopkg.lock%s\n", pr, nvSuffix)
case verify.EmptyDigestInLock:
logger.Printf("%s: no digest in Gopkg.lock to compare against hash of vendored tree%s\n", pr, nvSuffix)
case verify.HashVersionMismatch:
// This will double-print if the hash version is zero, but
// that's a rare case that really only occurs before the first
// run with a version of dep >=0.5.0, so it's fine.
logger.Printf("%s: hash algorithm mismatch, want version %v\n", pr, verify.HashVersion)
logger.Printf("%s: hash algorithm mismatch, want version %v%s\n", pr, verify.HashVersion, nvSuffix)
}
}
}
Expand All @@ -185,12 +209,12 @@ func sprintLockUnsat(lsat verify.LockSatisfaction) string {
var buf bytes.Buffer
sort.Strings(lsat.MissingImports)
for _, missing := range lsat.MissingImports {
fmt.Fprintf(&buf, "%s: missing from input-imports\n", missing)
fmt.Fprintf(&buf, "%s: imported or required, but missing from Gopkg.lock's input-imports\n", missing)
}

sort.Strings(lsat.ExcessImports)
for _, excess := range lsat.ExcessImports {
fmt.Fprintf(&buf, "%s: in input-imports, but not imported\n", excess)
fmt.Fprintf(&buf, "%s: in Gopkg.lock's input-imports, but neither imported nor required\n", excess)
}

var ordered []string
Expand Down
23 changes: 3 additions & 20 deletions cmd/dep/ensure.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,11 +285,7 @@ func (cmd *ensureCommand) runDefault(ctx *dep.Ctx, args []string, p *dep.Project
lock = dep.LockFromSolution(solution, p.Manifest.PruneOptions)
}

status, err := p.VerifyVendor()
if err != nil {
return errors.Wrap(err, "error while verifying vendor directory")
}
dw, err := dep.NewDeltaWriter(p.Lock, lock, status, p.Manifest.PruneOptions, filepath.Join(p.AbsRoot, "vendor"), cmd.vendorBehavior())
dw, err := dep.NewDeltaWriter(p, lock, cmd.vendorBehavior())
if err != nil {
return err
}
Expand Down Expand Up @@ -365,11 +361,7 @@ func (cmd *ensureCommand) runUpdate(ctx *dep.Ctx, args []string, p *dep.Project,
return handleAllTheFailuresOfTheWorld(err)
}

status, err := p.VerifyVendor()
if err != nil {
return errors.Wrap(err, "error while verifying vendor directory")
}
dw, err := dep.NewDeltaWriter(p.Lock, dep.LockFromSolution(solution, p.Manifest.PruneOptions), status, p.Manifest.PruneOptions, filepath.Join(p.AbsRoot, "vendor"), cmd.vendorBehavior())
dw, err := dep.NewDeltaWriter(p, dep.LockFromSolution(solution, p.Manifest.PruneOptions), cmd.vendorBehavior())
if err != nil {
return err
}
Expand Down Expand Up @@ -411,11 +403,6 @@ func (cmd *ensureCommand) runAdd(ctx *dep.Ctx, args []string, p *dep.Project, sm
}
}

//exrmap, err := p.GetDirectDependencyNames(sm)
//if err != nil {
//return err
//}

// Note: these flags are only partially used by the latter parts of the
// algorithm; rather, it relies on inference. However, they remain in their
// entirety as future needs may make further use of them, being a handy,
Expand Down Expand Up @@ -643,11 +630,7 @@ func (cmd *ensureCommand) runAdd(ctx *dep.Ctx, args []string, p *dep.Project, sm
}
sort.Strings(reqlist)

status, err := p.VerifyVendor()
if err != nil {
return errors.Wrap(err, "error while verifying vendor directory")
}
dw, err := dep.NewDeltaWriter(p.Lock, dep.LockFromSolution(solution, p.Manifest.PruneOptions), status, p.Manifest.PruneOptions, filepath.Join(p.AbsRoot, "vendor"), cmd.vendorBehavior())
dw, err := dep.NewDeltaWriter(p, dep.LockFromSolution(solution, p.Manifest.PruneOptions), cmd.vendorBehavior())
if err != nil {
return err
}
Expand Down
5 changes: 5 additions & 0 deletions cmd/dep/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,12 @@ func testIntegration(name, relPath, wd string, run integration.RunFunc) func(t *
}
}

if err != nil {
t.Log(err)
}

// Check error raised in final command
testCase.CompareCmdFailure(err != nil)
testCase.CompareError(err, testProj.GetStderr())

if *test.UpdateGolden {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Gopkg.lock is out of sync:
github.com/sdboyer/deptest: in input-imports, but not imported
github.com/sdboyer/deptest: in Gopkg.lock's input-imports, but neither imported nor required

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"commands": [
["check"]
],
"exit-code": 1,
"should-fail": true,
"vendor-final": []
}
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# vendor is out of sync:
github.com/sdboyer/deptest: hash of vendored tree didn't match digest in Gopkg.lock
github.com/sdboyer/deptest: hash of vendored tree not equal to digest in Gopkg.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"commands": [
["check"]
],
"exit-code": 1,
"should-fail": true,
"vendor-final": [
"github.com/sdboyer/deptest"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"commands": [
["check"]
],
"exit-code": 1,
"should-fail": true,
"vendor-final": [
"github.com/sdboyer/deptest"
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Gopkg.lock is out of sync:
github.com/sdboyer/deptestdos: missing from input-imports
github.com/sdboyer/deptest: in input-imports, but not imported
github.com/sdboyer/deptestdos: imported or required, but missing from Gopkg.lock's input-imports
github.com/sdboyer/deptest: in Gopkg.lock's input-imports, but neither imported nor required

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"commands": [
["check"]
],
"exit-code": 1,
"should-fail": true,
"vendor-final": []
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Gopkg.lock is out of sync:
github.com/sdboyer/deptestdos: missing from input-imports
github.com/sdboyer/deptestdos: imported or required, but missing from Gopkg.lock's input-imports

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"commands": [
["check"]
],
"exit-code": 1,
"should-fail": true,
"vendor-final": []
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
noverify = ["github.com/sdboyer/deptest"]

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
noverify = ["github.com/sdboyer/deptest"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package main

import (
_ "github.com/sdboyer/deptest"
)

func main() {
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github.com/sdboyer/deptest: hash of vendored tree not equal to digest in Gopkg.lock (CHECK IGNORED: marked noverify in Gopkg.toml)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"commands": [
["check"]
],
"vendor-final": [
"github.com/sdboyer/deptest"
]
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
noverify = ["github.com/sdboyer/deptest"]

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
noverify = ["github.com/sdboyer/deptest"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package main

import (
_ "github.com/sdboyer/deptest"
)

func main() {
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github.com/sdboyer/deptest: hash algorithm mismatch, want version 1 (CHECK IGNORED: marked noverify in Gopkg.toml)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"commands": [
["check"]
],
"vendor-final": [
"github.com/sdboyer/deptest"
]
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
noverify = ["github.com/sdboyer/deptest"]

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
noverify = ["github.com/sdboyer/deptest"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package main

import (
_ "github.com/sdboyer/deptestdos"
)

func main() {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Gopkg.lock is out of sync:
github.com/sdboyer/deptestdos: imported or required, but missing from Gopkg.lock's input-imports
github.com/sdboyer/deptest: in Gopkg.lock's input-imports, but neither imported nor required

Loading