Skip to content

Commit 90d7c35

Browse files
miguel250zknill
authored andcommitted
cmd/dep: make out-of-sync ensure less strict (golang#1225)
* cmd/dep: make out-of-sync ensure less strict * cmd/dep: fix broken integration test
1 parent 0a66b5e commit 90d7c35

File tree

21 files changed

+64
-50
lines changed

21 files changed

+64
-50
lines changed

cmd/dep/ensure.go

+3-5
Original file line numberDiff line numberDiff line change
@@ -340,9 +340,8 @@ func (cmd *ensureCommand) runUpdate(ctx *dep.Ctx, args []string, p *dep.Project,
340340
// user a bit, but the extra effort required is minimal, and it ensures the
341341
// user is isolating variables in the event of solve problems (was it the
342342
// "pending" changes, or the -update that caused the problem?).
343-
// TODO(sdboyer) reduce this to a warning?
344343
if !bytes.Equal(p.Lock.InputHash(), solver.HashInputs()) {
345-
return errors.Errorf("%s is out of sync with %s or the project's imports. Run \"dep ensure\" to resync them first before running \"dep ensure -update\"", dep.LockName, dep.ManifestName)
344+
ctx.Out.Printf("Warning: %s is out of sync with %s or the project's imports.", dep.LockName, dep.ManifestName)
346345
}
347346

348347
// When -update is specified without args, allow every dependency to change
@@ -406,9 +405,8 @@ func (cmd *ensureCommand) runAdd(ctx *dep.Ctx, args []string, p *dep.Project, sm
406405
// user a bit, but the extra effort required is minimal, and it ensures the
407406
// user is isolating variables in the event of solve problems (was it the
408407
// "pending" changes, or the -add that caused the problem?).
409-
// TODO(sdboyer) reduce this to a warning?
410408
if p.Lock != nil && !bytes.Equal(p.Lock.InputHash(), solver.HashInputs()) {
411-
return errors.Errorf("%s is out of sync with %s or the project's imports. Run \"dep ensure\" to resync them first before running \"dep ensure -add\"", dep.LockName, dep.ManifestName)
409+
ctx.Out.Printf("Warning: %s is out of sync with %s or the project's imports.", dep.LockName, dep.ManifestName)
412410
}
413411

414412
rm, _ := params.RootPackageTree.ToReachMap(true, true, false, p.Manifest.IgnoredPackages())
@@ -479,7 +477,7 @@ func (cmd *ensureCommand) runAdd(ctx *dep.Ctx, args []string, p *dep.Project, sm
479477

480478
var wg sync.WaitGroup
481479

482-
fmt.Println("Fetching sources...")
480+
ctx.Out.Println("Fetching sources...")
483481

484482
for i, arg := range args {
485483
wg.Add(1)

cmd/dep/testdata/harness_tests/ensure/update/errs/desync/final/Gopkg.lock cmd/dep/testdata/harness_tests/ensure/add/desync/final/Gopkg.lock

+10-4
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,6 @@
1+
[[constraint]]
2+
name = "github.com/sdboyer/deptest"
3+
version = "~0.8.0"
4+
[[constraint]]
5+
branch = "master"
6+
name = "github.com/sdboyer/deptesttres"

cmd/dep/testdata/harness_tests/ensure/add/desync/initial/Gopkg.lock

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

cmd/dep/testdata/harness_tests/ensure/update/errs/desync/initial/main.go cmd/dep/testdata/harness_tests/ensure/add/desync/initial/main.go

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package main
77
import (
88
"github.com/sdboyer/deptest"
99
"github.com/sdboyer/deptestdos"
10+
"github.com/sdboyer/deptesttres"
1011
)
1112

1213
func main() {
@@ -15,4 +16,6 @@ func main() {
1516
deptest.Map["yo yo!"]
1617
}
1718
deptestdos.diMeLo("whatev")
19+
20+
type a deptesttres.Bar
1821
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Warning: Gopkg.lock is out of sync with Gopkg.toml or the project's imports.
2+
Fetching sources...
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"commands": [
3+
["ensure", "-add", "github.com/sdboyer/deptesttres@master"]
4+
],
5+
"vendor-final": [
6+
"github.com/sdboyer/deptest",
7+
"github.com/sdboyer/deptestdos",
8+
"github.com/sdboyer/deptesttres"
9+
]
10+
}

cmd/dep/testdata/harness_tests/ensure/add/errs/desync/testcase.json

-6
This file was deleted.

cmd/dep/testdata/harness_tests/ensure/add/errs/desync/initial/Gopkg.lock cmd/dep/testdata/harness_tests/ensure/update/desync/final/Gopkg.lock

+5-5
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+
Warning: Gopkg.lock is out of sync with Gopkg.toml or the project's imports.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"commands": [
3+
["ensure", "-update"]
4+
],
5+
"vendor-final": [
6+
"github.com/sdboyer/deptest",
7+
"github.com/sdboyer/deptestdos"
8+
]
9+
}

cmd/dep/testdata/harness_tests/ensure/update/errs/desync/initial/Gopkg.lock

-21
This file was deleted.

cmd/dep/testdata/harness_tests/ensure/update/errs/desync/initial/Gopkg.toml

-3
This file was deleted.

cmd/dep/testdata/harness_tests/ensure/update/errs/desync/testcase.json

-6
This file was deleted.

0 commit comments

Comments
 (0)