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

Meta-merge of all changes to stabilize Gopkg.{toml,lock} #644

Merged
merged 23 commits into from
May 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
ff254a8
rename for constraint
felipeweb May 9, 2017
b76e416
fixtures rename
felipeweb May 9, 2017
942792a
fix tests
felipeweb May 9, 2017
bb8a327
update Gopkg.toml
felipeweb May 9, 2017
5cb3e51
rename [[overrides]] to [[override]]
felipeweb May 10, 2017
8be9bb6
Split input components out in Gopkg.lock
sdboyer May 16, 2017
2081136
s/LockFromInterface/LockFromSolution/
sdboyer May 16, 2017
bf737b6
Expand Solver, Solution to report name/version
sdboyer May 22, 2017
75ac569
Incorporate solver name and version in Gopkg.lock
sdboyer May 22, 2017
f6c2b15
Incorporate lock split-up into integration branch
sdboyer May 22, 2017
f0a81f4
Incorporate pr/538, change manifest prop names
sdboyer May 23, 2017
0081879
Respond to review
sdboyer May 23, 2017
ab84520
Merge branch 'split-up-hash' into stabilize-files
sdboyer May 23, 2017
2e9aecc
Update FAQ with new Gopkg.toml key names
sdboyer May 24, 2017
a75d6d2
Support implied carets in gps
carolynvs May 24, 2017
ecf43b9
Always use implied carets in dep
carolynvs May 24, 2017
5285e62
Preserve previous test behavior before implied caret
carolynvs May 24, 2017
8dcaab5
Fix deduceConstraint test to not rely upon the types being comparable
carolynvs May 23, 2017
16e350f
Update testdata now that init omits carets in the manifest
carolynvs May 24, 2017
a926aa2
Incorporate implicit caret into stabilize-files
sdboyer May 25, 2017
f1bd538
Tidy up docs a bit
sdboyer May 25, 2017
4df9c95
Update Gopkg.toml, Gopkg.lock to new forms
sdboyer May 25, 2017
ec6c4e8
Fix out-of-date vendor
sdboyer May 25, 2017
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
8 changes: 4 additions & 4 deletions FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Please contribute to the FAQ! Found an explanation in an issue or pull request h
Summarize the question and quote the reply, linking back to the original comment.

* [What is the difference between Gopkg.toml (the "manifest") and Gopkg.lock (the "lock")?](#what-is-the-difference-between-gopkgtoml-the-manifest-and-gopkglock-the-lock)
* [When should I use dependencies, overrides or required in the manifest?](#when-should-i-use-dependencies-overrides-required-or-ignored-in-the-manifest)
* [When should I use `constraint`, `override` `required`, or `ignored` in the Gopkg.toml?](#when-should-i-use-constraint-override-required-or-ignored-in-gopkgtoml)
* [What is a direct or transitive dependency?](#what-is-a-direct-or-transitive-dependency)
* [Should I commit my vendor directory?](#should-i-commit-my-vendor-directory)
* [Why is it `dep ensure` instead of `dep install`?](#why-is-it-dep-ensure-instead-of-dep-install)
Expand All @@ -27,10 +27,10 @@ Summarize the question and quote the reply, linking back to the original comment
> This flexibility is important because it allows us to provide easy commands (e.g. `dep ensure -update`) that can manage an update process for you, within the constraints you specify, AND because it allows your project, when imported by someone else, to collaboratively specify the constraints for your own dependencies.
-[@sdboyer in #281](https://github.com/golang/dep/issues/281#issuecomment-284118314)

## When should I use dependencies, overrides, required, or ignored in the manifest?
## When should I use `constraint`, `override`, `required`, or `ignored` in `Gopkg.toml`?

* Use `dependencies` to constrain a [direct dependency](#what-is-a-direct-or-transitive-dependency) to a specific branch, version range, revision, or specify an alternate source such as a fork.
* Use `overrides` to constrain a [transitive dependency](#what-is-a-direct-or-transitive-dependency). See [How do I constrain a transitive dependency's version?](#how-do-i-constrain-a-transitive-dependencys-version) for more details on how overrides differ from dependencies. Overrides should be used cautiously, sparingly, and temporarily.
* Use `constraint` to constrain a [direct dependency](#what-is-a-direct-or-transitive-dependency) to a specific branch, version range, revision, or specify an alternate source such as a fork.
* Use `override` to constrain a [transitive dependency](#what-is-a-direct-or-transitive-dependency). See [How do I constrain a transitive dependency's version?](#how-do-i-constrain-a-transitive-dependencys-version) for more details on how overrides differ from dependencies. Overrides should be used cautiously, sparingly, and temporarily.
* Use `required` to explicitly add a dependency that is not imported directly or transitively, for example a development package used for code generation.
* Use `ignored` to ignore a package and any of that package's unique dependencies.

Expand Down
10 changes: 9 additions & 1 deletion Gopkg.lock

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

14 changes: 6 additions & 8 deletions Gopkg.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
required = ["github.com/Masterminds/semver"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this required to begin with? I would have thought the direct dependency (below) would have been enough, so I'm not sure why it was needed before and not anymore?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for a while there (pre gps move) we didn't directly import it, and thus couldn't constrain it, so we kept getting the wrong version.


[[dependencies]]
[[constraint]]
branch = "2.x"
name = "github.com/Masterminds/semver"

[[dependencies]]
[[constraint]]
name = "github.com/Masterminds/vcs"
version = "^1.11.0"
version = "1.11.0"

[[dependencies]]
[[constraint]]
branch = "master"
name = "github.com/pelletier/go-toml"

[[dependencies]]
[[constraint]]
name = "github.com/pkg/errors"
version = ">=0.8.0, <1.0.0"
version = "0.8.0"
8 changes: 4 additions & 4 deletions cmd/dep/ensure.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func (cmd *ensureCommand) Run(ctx *dep.Ctx, args []string) error {
writeV = dep.VendorAlways
}

newLock := dep.LockFromInterface(solution)
newLock := dep.LockFromSolution(solution)
sw, err := dep.NewSafeWriter(nil, p.Lock, newLock, writeV)
if err != nil {
return err
Expand Down Expand Up @@ -205,14 +205,14 @@ func applyEnsureArgs(logger *log.Logger, args []string, overrides stringSlice, p
//
// TODO(sdboyer): for this case - or just in general - do we want to
// add project args to the requires list temporarily for this run?
if _, has := p.Manifest.Dependencies[pc.Ident.ProjectRoot]; !has {
if _, has := p.Manifest.Constraints[pc.Ident.ProjectRoot]; !has {
logger.Printf("dep: No constraint or alternate source specified for %q, omitting from manifest\n", pc.Ident.ProjectRoot)
}
// If it's already in the manifest, no need to log
continue
}

p.Manifest.Dependencies[pc.Ident.ProjectRoot] = gps.ProjectProperties{
p.Manifest.Constraints[pc.Ident.ProjectRoot] = gps.ProjectProperties{
Source: pc.Ident.Source,
Constraint: pc.Constraint,
}
Expand Down Expand Up @@ -329,7 +329,7 @@ func getProjectConstraint(arg string, sm gps.SourceManager) (gps.ProjectConstrai
// semver, a revision, or as a fallback, a plain tag
func deduceConstraint(s string) gps.Constraint {
// always semver if we can
c, err := gps.NewSemverConstraint(s)
c, err := gps.NewSemverConstraintIC(s)
if err == nil {
return c
}
Expand Down
17 changes: 12 additions & 5 deletions cmd/dep/ensure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package main

import (
"reflect"
"testing"

"github.com/golang/dep/internal/gps"
Expand All @@ -13,7 +14,7 @@ import (
func TestDeduceConstraint(t *testing.T) {
t.Parallel()

sv, err := gps.NewSemverConstraint("v1.2.3")
sv, err := gps.NewSemverConstraintIC("v1.2.3")
if err != nil {
t.Fatal(err)
}
Expand All @@ -31,10 +32,16 @@ func TestDeduceConstraint(t *testing.T) {
"20120425195858-psty8c35ve2oej8t": gps.NewVersion("20120425195858-psty8c35ve2oej8t"),
}

for str, expected := range constraints {
c := deduceConstraint(str)
if c != expected {
t.Fatalf("expected: %#v, got %#v for %s", expected, c, str)
for str, want := range constraints {
got := deduceConstraint(str)

wantT := reflect.TypeOf(want)
gotT := reflect.TypeOf(got)
if wantT != gotT {
t.Errorf("expected type: %s, got %s, for input %s", wantT, gotT, str)
}
if got.String() != want.String() {
t.Errorf("expected value: %s, got %s for input %s", want, got, str)
}
}
}
11 changes: 5 additions & 6 deletions cmd/dep/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func (cmd *initCommand) Run(ctx *dep.Ctx, args []string) error {
return err
}
m := &dep.Manifest{
Dependencies: pd.constraints,
Constraints: pd.constraints,
}

// Make an initial lock from what knowledge we've collected about the
Expand Down Expand Up @@ -185,7 +185,7 @@ func (cmd *initCommand) Run(ctx *dep.Ctx, args []string) error {
handleAllTheFailuresOfTheWorld(err)
return err
}
l = dep.LockFromInterface(soln)
l = dep.LockFromSolution(soln)

// Iterate through the new projects in solved lock and add them to manifest
// if direct deps
Expand All @@ -201,7 +201,7 @@ func (cmd *initCommand) Run(ctx *dep.Ctx, args []string) error {
if newProject {
// If it's in notondisk, add to manifest, these are direct dependencies.
if _, ok := pd.notondisk[pr]; ok {
m.Dependencies[pr] = getProjectPropertiesFromVersion(x.Version())
m.Constraints[pr] = getProjectPropertiesFromVersion(x.Version())
}
}
}
Expand All @@ -213,7 +213,7 @@ func (cmd *initCommand) Run(ctx *dep.Ctx, args []string) error {
return errors.Wrap(err, "prepare solver")
}

l.Memo = s.HashInputs()
l.SolveMeta.Memo = s.HashInputs()

// Pass timestamp (yyyyMMddHHmmss format) as suffix to backup name.
vendorbak, err := dep.BackupVendor(vpath, time.Now().Format("20060102150405"))
Expand Down Expand Up @@ -319,8 +319,7 @@ func getProjectPropertiesFromVersion(v gps.Version) gps.ProjectProperties {
case gps.IsBranch, gps.IsVersion:
pp.Constraint = v
case gps.IsSemver:
// TODO: remove "^" when https://github.com/golang/dep/issues/225 is ready.
c, err := gps.NewSemverConstraint("^" + v.String())
c, err := gps.NewSemverConstraintIC(v.String())
if err != nil {
panic(err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/dep/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestContains(t *testing.T) {
func TestGetProjectPropertiesFromVersion(t *testing.T) {
t.Parallel()

wantSemver, _ := gps.NewSemverConstraint("^v1.0.0")
wantSemver, _ := gps.NewSemverConstraintIC("v1.0.0")
cases := []struct {
version, want gps.Constraint
}{
Expand Down
2 changes: 1 addition & 1 deletion cmd/dep/prune.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (cmd *pruneCommand) Run(ctx *dep.Ctx, args []string) error {
return errors.Wrap(err, "could not set up solver for input hashing")
}

if !bytes.Equal(s.HashInputs(), p.Lock.Memo) {
if !bytes.Equal(s.HashInputs(), p.Lock.SolveMeta.Memo) {
return fmt.Errorf("lock hash doesn't match")
}

Expand Down
10 changes: 5 additions & 5 deletions cmd/dep/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ func (cmd *removeCommand) Run(ctx *dep.Ctx, args []string) error {
}

var rm []gps.ProjectRoot
for pr := range p.Manifest.Dependencies {
for pr := range p.Manifest.Constraints {
if _, has := otherroots[pr]; !has {
delete(p.Manifest.Dependencies, pr)
delete(p.Manifest.Constraints, pr)
rm = append(rm, pr)
}
}
Expand Down Expand Up @@ -145,7 +145,7 @@ func (cmd *removeCommand) Run(ctx *dep.Ctx, args []string) error {
}
}

if _, indeps := p.Manifest.Dependencies[gps.ProjectRoot(arg)]; !indeps {
if _, indeps := p.Manifest.Constraints[gps.ProjectRoot(arg)]; !indeps {
return errors.Errorf("%q is not present in the manifest, cannot remove it", arg)
}

Expand All @@ -156,7 +156,7 @@ func (cmd *removeCommand) Run(ctx *dep.Ctx, args []string) error {
return errors.Errorf("not removing %q because it is imported by:\n\t%s (pass -force to override)", arg, strings.Join(pkgimport, "\n\t"))
}

delete(p.Manifest.Dependencies, gps.ProjectRoot(arg))
delete(p.Manifest.Constraints, gps.ProjectRoot(arg))
}
}

Expand All @@ -177,7 +177,7 @@ func (cmd *removeCommand) Run(ctx *dep.Ctx, args []string) error {
return err
}

newLock := dep.LockFromInterface(soln)
newLock := dep.LockFromSolution(soln)

sw, err := dep.NewSafeWriter(nil, p.Lock, newLock, dep.VendorOnChanged)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions cmd/dep/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ func runStatusAll(loggers *dep.Loggers, out outputter, p *dep.Project, sm gps.So
slp := p.Lock.Projects()
sort.Sort(dep.SortedLockedProjects(slp))

if bytes.Equal(s.HashInputs(), p.Lock.Memo) {
if bytes.Equal(s.HashInputs(), p.Lock.SolveMeta.Memo) {
// If these are equal, we're guaranteed that the lock is a transitively
// complete picture of all deps. That eliminates the need for at least
// some checks.
Expand Down Expand Up @@ -331,7 +331,7 @@ func runStatusAll(loggers *dep.Loggers, out outputter, p *dep.Project, sm gps.So
// Only if we have a non-rev and non-plain version do/can we display
// anything wrt the version's updateability.
if bs.Version != nil && bs.Version.Type() != gps.IsVersion {
c, has := p.Manifest.Dependencies[proj.Ident().ProjectRoot]
c, has := p.Manifest.Constraints[proj.Ident().ProjectRoot]
if !has {
c.Constraint = gps.Any()
}
Expand Down

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
Expand Up @@ -12,9 +12,10 @@
## or in a dependency.
# ignored = ["github.com/user/project/badpkg"]

## Dependencies define constraints on dependent projects. They are respected by
## Constraints are rules for how directly imported projects
## may be incorporated into the depgraph. They are respected by
## dep whether coming from the Gopkg.toml of the current project or a dependency.
# [[dependencies]]
# [[constraint]]
## Required: the root import path of the project being constrained.
# name = "github.com/user/project"
#
Expand All @@ -27,12 +28,12 @@
## Optional: an alternate location (URL or import path) for the project's source.
# source = "https://github.com/myfork/package.git"

## Overrides have the same structure as [[dependencies]], but supercede all
## [[dependencies]] declarations from all projects. Only the current project's
## [[overrides]] are applied.
## Override have the same structure as [[constraint]], but supercede all
## [[constraint]] declarations from all projects. Only the current project's
## [[override]] is applied.
##
## Overrides are a sledgehammer. Use them only as a last resort.
# [[overrides]]
## Override is a sledgehammer. Use them only as a last resort.
# [[override]]
## Required: the root import path of the project being constrained.
# name = "github.com/user/project"
#
Expand All @@ -51,6 +52,6 @@



[[dependencies]]
[[constraint]]
name = "github.com/sdboyer/deptest"
version = "^1.0.0"
version = "1.0.0"

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
@@ -1,3 +1,3 @@
[[dependencies]]
[[constraint]]
name = "github.com/sdboyer/deptest"
version = "~0.8.0"
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[[dependencies]]
[[constraint]]
name = "github.com/sdboyer/deptest"
version = "~0.8.0"

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
@@ -1,5 +1,5 @@
ignored = ["github.com/sdboyer/deptestdos"]

[[dependencies]]
[[constraint]]
branch = "master"
name = "github.com/sdboyer/deptest"
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ignored = ["github.com/sdboyer/deptestdos"]

[[dependencies]]
[[constraint]]
branch = "master"
name = "github.com/sdboyer/deptest"

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

Loading