Merge meta-PR to stabilize Gopkg metadata files

This commit is contained in:
sam boyer 2017-05-26 23:50:29 -04:00
Родитель 3e187c966e ec6c4e8cdb
Коммит 05c40eba7f
86 изменённых файлов: 571 добавлений и 366 удалений

8
FAQ.md
Просмотреть файл

@ -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)
@ -32,10 +32,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.

9
Gopkg.lock сгенерированный
Просмотреть файл

@ -1,7 +1,5 @@
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
memo = "932b7b1663f6eecccb1fada1d3670ae24cd8aa7c8b61e3b224edfefebe25954e"
[[projects]]
branch = "2.x"
name = "github.com/Masterminds/semver"
@ -43,3 +41,10 @@ memo = "932b7b1663f6eecccb1fada1d3670ae24cd8aa7c8b61e3b224edfefebe25954e"
name = "github.com/sdboyer/constext"
packages = ["."]
revision = "836a144573533ea4da4e6929c235fd348aed1c80"
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
inputs-digest = "932b7b1663f6eecccb1fada1d3670ae24cd8aa7c8b61e3b224edfefebe25954e"
solver-name = "gps-cdcl"
solver-version = 1

Просмотреть файл

@ -1,17 +1,15 @@
required = ["github.com/Masterminds/semver"]
[[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"

Просмотреть файл

@ -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
@ -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,
}
@ -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
}

Просмотреть файл

@ -5,6 +5,7 @@
package main
import (
"reflect"
"testing"
"github.com/golang/dep/internal/gps"
@ -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)
}
@ -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)
}
}
}

Просмотреть файл

@ -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
@ -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
@ -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())
}
}
}
@ -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.InputsDigest = s.HashInputs()
// Pass timestamp (yyyyMMddHHmmss format) as suffix to backup name.
vendorbak, err := dep.BackupVendor(vpath, time.Now().Format("20060102150405"))
@ -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)
}

Просмотреть файл

@ -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
}{

Просмотреть файл

@ -72,8 +72,8 @@ func (cmd *pruneCommand) Run(ctx *dep.Ctx, args []string) error {
return errors.Errorf("Gopkg.lock must exist for prune to know what files are safe to remove.")
}
if !bytes.Equal(s.HashInputs(), p.Lock.Memo) {
return errors.Errorf("lock hash doesn't match")
if !bytes.Equal(s.HashInputs(), p.Lock.SolveMeta.InputsDigest) {
return errors.Errorf("Gopkg.lock is out of sync the project; run dep ensure before pruning.")
}
var pruneLogger *log.Logger

Просмотреть файл

@ -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)
}
}
@ -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)
}
@ -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))
}
}
@ -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 {

Просмотреть файл

@ -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.InputsDigest) {
// 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.
@ -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()
}

8
cmd/dep/testdata/harness_tests/ensure/empty/case1/final/Gopkg.lock сгенерированный поставляемый
Просмотреть файл

@ -1,9 +1,15 @@
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
memo = "14b07b05e0f01051b03887ab2bf80b516bc5510ea92f75f76c894b1745d8850c"
[[projects]]
name = "github.com/sdboyer/deptest"
packages = ["."]
revision = "ff2948a2ac8f538c4ecd55962e919d1e13e74baf"
version = "v1.0.0"
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
inputs-digest = "14b07b05e0f01051b03887ab2bf80b516bc5510ea92f75f76c894b1745d8850c"
solver-name = "gps-cdcl"
solver-version = 1

Просмотреть файл

@ -1,70 +1,4 @@
## Gopkg.toml example (these lines may be deleted)
## "metadata" defines metadata about the project that could be used by other independent
## systems. The metadata defined here will be ignored by dep.
# [metadata]
# key1 = "value that convey data to other systems"
# system1-data = "value that is used by a system"
# system2-data = "value that is used by another system"
## "required" lists a set of packages (not projects) that must be included in
## Gopkg.lock. This list is merged with the set of packages imported by the current
## project. Use it when your project needs a package it doesn't explicitly import -
## including "main" packages.
# required = ["github.com/user/thing/cmd/thing"]
## "ignored" lists a set of packages (not projects) that are ignored when
## dep statically analyzes source code. Ignored packages can be in this project,
## or in a dependency.
# ignored = ["github.com/user/project/badpkg"]
## Dependencies define constraints on dependent projects. They are respected by
## dep whether coming from the Gopkg.toml of the current project or a dependency.
# [[dependencies]]
## Required: the root import path of the project being constrained.
# name = "github.com/user/project"
#
## Recommended: the version constraint to enforce for the project.
## Only one of "branch", "version" or "revision" can be specified.
# version = "1.0.0"
# branch = "master"
# revision = "abc123"
#
## Optional: an alternate location (URL or import path) for the project's source.
# source = "https://github.com/myfork/package.git"
#
## "metadata" defines metadata about the dependency or override that could be used
## by other independent systems. The metadata defined here will be ignored by dep.
# [metadata]
# key1 = "value that convey data to other systems"
# system1-data = "value that is used by a system"
# system2-data = "value that is used by another system"
## Overrides have the same structure as [[dependencies]], but supersede all
## [[dependencies]] declarations from all projects. Only the current project's
## [[overrides]] are applied.
##
## Overrides are a sledgehammer. Use them only as a last resort.
# [[overrides]]
## Required: the root import path of the project being constrained.
# name = "github.com/user/project"
#
## Optional: specifying a version constraint override will cause all other
## constraints on this project to be ignored; only the overridden constraint
## need be satisfied.
## Again, only one of "branch", "version" or "revision" can be specified.
# version = "1.0.0"
# branch = "master"
# revision = "abc123"
#
## Optional: specifying an alternate source location as an override will
## enforce that the alternate location is used for that project, regardless of
## what source location any dependent projects specify.
# source = "https://github.com/myfork/package.git"
[[dependencies]]
[[constraint]]
name = "github.com/sdboyer/deptest"
version = "^1.0.0"
version = "1.0.0"

8
cmd/dep/testdata/harness_tests/ensure/empty/case2/final/Gopkg.lock сгенерированный поставляемый
Просмотреть файл

@ -1,9 +1,15 @@
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
memo = "e7725ea56516a42a641aaaf5d48754258d9f3c59949cb8a0e8a21b1ab6e07179"
[[projects]]
name = "github.com/sdboyer/deptest"
packages = ["."]
revision = "ff2948a2ac8f538c4ecd55962e919d1e13e74baf"
version = "v1.0.0"
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
inputs-digest = "e7725ea56516a42a641aaaf5d48754258d9f3c59949cb8a0e8a21b1ab6e07179"
solver-name = "gps-cdcl"
solver-version = 1

Просмотреть файл

@ -1,3 +1,3 @@
[[dependencies]]
[[constraint]]
name = "github.com/sdboyer/deptest"
version = "~0.8.0"

Просмотреть файл

@ -1,3 +1,3 @@
[[dependencies]]
[[constraint]]
name = "github.com/sdboyer/deptest"
version = "~0.8.0"

8
cmd/dep/testdata/harness_tests/ensure/empty/case3/final/Gopkg.lock сгенерированный поставляемый
Просмотреть файл

@ -1,9 +1,15 @@
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
memo = "e5c16e09ed6f0a1a2b3cf472c34b7fd50861dd070e81d5e623f72e8173f0c065"
[[projects]]
branch = "master"
name = "github.com/sdboyer/deptest"
packages = ["."]
revision = "3f4c3bea144e112a69bbe5d8d01c1b09a544253f"
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
inputs-digest = "e5c16e09ed6f0a1a2b3cf472c34b7fd50861dd070e81d5e623f72e8173f0c065"
solver-name = "gps-cdcl"
solver-version = 1

Просмотреть файл

@ -1,5 +1,5 @@
ignored = ["github.com/sdboyer/deptestdos"]
[[dependencies]]
[[constraint]]
branch = "master"
name = "github.com/sdboyer/deptest"

Просмотреть файл

@ -1,5 +1,5 @@
ignored = ["github.com/sdboyer/deptestdos"]
[[dependencies]]
[[constraint]]
branch = "master"
name = "github.com/sdboyer/deptest"

8
cmd/dep/testdata/harness_tests/ensure/override/case1/final/Gopkg.lock сгенерированный поставляемый
Просмотреть файл

@ -1,9 +1,15 @@
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
memo = "8bca9526e654e56e05d9075d1f33fa5b649bf6d58aa7d71ca39e7fbea8468e07"
[[projects]]
name = "github.com/sdboyer/deptest"
packages = ["."]
revision = "ff2948a2ac8f538c4ecd55962e919d1e13e74baf"
version = "v1.0.0"
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
inputs-digest = "8bca9526e654e56e05d9075d1f33fa5b649bf6d58aa7d71ca39e7fbea8468e07"
solver-name = "gps-cdcl"
solver-version = 1

Просмотреть файл

@ -1,70 +1,4 @@
## Gopkg.toml example (these lines may be deleted)
## "metadata" defines metadata about the project that could be used by other independent
## systems. The metadata defined here will be ignored by dep.
# [metadata]
# key1 = "value that convey data to other systems"
# system1-data = "value that is used by a system"
# system2-data = "value that is used by another system"
## "required" lists a set of packages (not projects) that must be included in
## Gopkg.lock. This list is merged with the set of packages imported by the current
## project. Use it when your project needs a package it doesn't explicitly import -
## including "main" packages.
# required = ["github.com/user/thing/cmd/thing"]
## "ignored" lists a set of packages (not projects) that are ignored when
## dep statically analyzes source code. Ignored packages can be in this project,
## or in a dependency.
# ignored = ["github.com/user/project/badpkg"]
## Dependencies define constraints on dependent projects. They are respected by
## dep whether coming from the Gopkg.toml of the current project or a dependency.
# [[dependencies]]
## Required: the root import path of the project being constrained.
# name = "github.com/user/project"
#
## Recommended: the version constraint to enforce for the project.
## Only one of "branch", "version" or "revision" can be specified.
# version = "1.0.0"
# branch = "master"
# revision = "abc123"
#
## Optional: an alternate location (URL or import path) for the project's source.
# source = "https://github.com/myfork/package.git"
#
## "metadata" defines metadata about the dependency or override that could be used
## by other independent systems. The metadata defined here will be ignored by dep.
# [metadata]
# key1 = "value that convey data to other systems"
# system1-data = "value that is used by a system"
# system2-data = "value that is used by another system"
## Overrides have the same structure as [[dependencies]], but supersede all
## [[dependencies]] declarations from all projects. Only the current project's
## [[overrides]] are applied.
##
## Overrides are a sledgehammer. Use them only as a last resort.
# [[overrides]]
## Required: the root import path of the project being constrained.
# name = "github.com/user/project"
#
## Optional: specifying a version constraint override will cause all other
## constraints on this project to be ignored; only the overridden constraint
## need be satisfied.
## Again, only one of "branch", "version" or "revision" can be specified.
# version = "1.0.0"
# branch = "master"
# revision = "abc123"
#
## Optional: specifying an alternate source location as an override will
## enforce that the alternate location is used for that project, regardless of
## what source location any dependent projects specify.
# source = "https://github.com/myfork/package.git"
[[dependencies]]
[[constraint]]
name = "github.com/sdboyer/deptest"
version = "^1.0.0"
version = "1.0.0"

Просмотреть файл

@ -1,7 +1,7 @@
{
"commands": [
["init"],
["ensure", "-override", "github.com/sdboyer/deptest@1.0.0"]
["ensure", "-override", "github.com/sdboyer/deptest@=1.0.0"]
],
"error-expected": "",
"vendor-final": [

8
cmd/dep/testdata/harness_tests/ensure/pkg-errors/case1/final/Gopkg.lock сгенерированный поставляемый
Просмотреть файл

@ -1,3 +1,9 @@
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
memo = "ab4fef131ee828e96ba67d31a7d690bd5f2f42040c6766b1b12fe856f87e0ff7"
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
inputs-digest = "ab4fef131ee828e96ba67d31a7d690bd5f2f42040c6766b1b12fe856f87e0ff7"
solver-name = "gps-cdcl"
solver-version = 1

8
cmd/dep/testdata/harness_tests/ensure/update/case1/final/Gopkg.lock сгенерированный поставляемый
Просмотреть файл

@ -1,6 +1,5 @@
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
memo = "1b381263a360eafafe3ef7f9be626672668d17250a3c9a8debd169d1b5e2eebb"
[[projects]]
name = "github.com/sdboyer/deptest"
@ -13,3 +12,10 @@ memo = "1b381263a360eafafe3ef7f9be626672668d17250a3c9a8debd169d1b5e2eebb"
packages = ["."]
revision = "5c607206be5decd28e6263ffffdcee067266015e"
version = "v2.0.0"
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
inputs-digest = "1b381263a360eafafe3ef7f9be626672668d17250a3c9a8debd169d1b5e2eebb"
solver-name = "gps-cdcl"
solver-version = 1

Просмотреть файл

@ -1,3 +1,3 @@
[[dependencies]]
[[constraint]]
name = "github.com/sdboyer/deptest"
version = "~0.8.0"

Просмотреть файл

@ -1,3 +1,3 @@
[[dependencies]]
[[constraint]]
name = "github.com/sdboyer/deptest"
version = "~0.8.0"

Просмотреть файл

@ -1,3 +1,3 @@
[[dependencies]]
[[constraint]]
name = "github.com/sdboyer/deptest"
version = "~0.8.0"

Просмотреть файл

@ -1,3 +1,3 @@
[[dependencies]]
[[constraint]]
name = "github.com/sdboyer/deptest"
version = "~0.8.0"

8
cmd/dep/testdata/harness_tests/init/case1/final/Gopkg.lock сгенерированный поставляемый
Просмотреть файл

@ -1,6 +1,5 @@
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
memo = "1b381263a360eafafe3ef7f9be626672668d17250a3c9a8debd169d1b5e2eebb"
[[projects]]
name = "github.com/sdboyer/deptest"
@ -12,3 +11,10 @@ memo = "1b381263a360eafafe3ef7f9be626672668d17250a3c9a8debd169d1b5e2eebb"
name = "github.com/sdboyer/deptestdos"
packages = ["."]
revision = "a0196baa11ea047dd65037287451d36b861b00ea"
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
inputs-digest = "1b381263a360eafafe3ef7f9be626672668d17250a3c9a8debd169d1b5e2eebb"
solver-name = "gps-cdcl"
solver-version = 1

Просмотреть файл

@ -1,4 +1,4 @@
[[dependencies]]
[[constraint]]
name = "github.com/sdboyer/deptest"
version = "^0.8.0"
version = "0.8.0"

8
cmd/dep/testdata/harness_tests/init/case2/final/Gopkg.lock сгенерированный поставляемый
Просмотреть файл

@ -1,6 +1,5 @@
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
memo = "ced51326ad990b11098d8076d0f7d72d89eee1ba6e8dacc7bc73be05cddac438"
[[projects]]
name = "github.com/sdboyer/deptest"
@ -13,3 +12,10 @@ memo = "ced51326ad990b11098d8076d0f7d72d89eee1ba6e8dacc7bc73be05cddac438"
packages = ["."]
revision = "5c607206be5decd28e6263ffffdcee067266015e"
version = "v2.0.0"
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
inputs-digest = "ced51326ad990b11098d8076d0f7d72d89eee1ba6e8dacc7bc73be05cddac438"
solver-name = "gps-cdcl"
solver-version = 1

Просмотреть файл

@ -1,8 +1,8 @@
[[dependencies]]
[[constraint]]
name = "github.com/sdboyer/deptest"
version = "^0.8.0"
version = "0.8.0"
[[dependencies]]
[[constraint]]
name = "github.com/sdboyer/deptestdos"
version = "^2.0.0"
version = "2.0.0"

8
cmd/dep/testdata/harness_tests/init/case3/final/Gopkg.lock сгенерированный поставляемый
Просмотреть файл

@ -1,6 +1,5 @@
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
memo = "af9a783a5430dabcaaf44683c09e2b729e1c0d61f13bfdf6677c4fd0b41387ca"
[[projects]]
branch = "master"
@ -12,3 +11,10 @@ memo = "af9a783a5430dabcaaf44683c09e2b729e1c0d61f13bfdf6677c4fd0b41387ca"
name = "github.com/sdboyer/deptestdos"
packages = ["."]
revision = "a0196baa11ea047dd65037287451d36b861b00ea"
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
inputs-digest = "af9a783a5430dabcaaf44683c09e2b729e1c0d61f13bfdf6677c4fd0b41387ca"
solver-name = "gps-cdcl"
solver-version = 1

Просмотреть файл

@ -1,4 +1,4 @@
[[dependencies]]
[[constraint]]
branch = "master"
name = "github.com/sdboyer/deptest"

8
cmd/dep/testdata/harness_tests/init/skip-hidden/final/Gopkg.lock сгенерированный поставляемый
Просмотреть файл

@ -1,9 +1,15 @@
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
memo = "14b07b05e0f01051b03887ab2bf80b516bc5510ea92f75f76c894b1745d8850c"
[[projects]]
name = "github.com/sdboyer/deptest"
packages = ["."]
revision = "ff2948a2ac8f538c4ecd55962e919d1e13e74baf"
version = "v1.0.0"
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
inputs-digest = "14b07b05e0f01051b03887ab2bf80b516bc5510ea92f75f76c894b1745d8850c"
solver-name = "gps-cdcl"
solver-version = 1

Просмотреть файл

@ -1,4 +1,4 @@
[[dependencies]]
[[constraint]]
name = "github.com/sdboyer/deptest"
version = "^1.0.0"
version = "1.0.0"

8
cmd/dep/testdata/harness_tests/remove/force/case1/final/Gopkg.lock сгенерированный поставляемый
Просмотреть файл

@ -1,6 +1,5 @@
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
memo = "1b381263a360eafafe3ef7f9be626672668d17250a3c9a8debd169d1b5e2eebb"
[[projects]]
name = "github.com/sdboyer/deptest"
@ -13,3 +12,10 @@ memo = "1b381263a360eafafe3ef7f9be626672668d17250a3c9a8debd169d1b5e2eebb"
packages = ["."]
revision = "5c607206be5decd28e6263ffffdcee067266015e"
version = "v2.0.0"
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
inputs-digest = "1b381263a360eafafe3ef7f9be626672668d17250a3c9a8debd169d1b5e2eebb"
solver-name = "gps-cdcl"
solver-version = 1

Просмотреть файл

@ -1,11 +1,11 @@
[[dependencies]]
[[constraint]]
name = "github.com/not/used"
version = "2.0.0"
[[dependencies]]
[[constraint]]
name = "github.com/sdboyer/deptest"
version = "^0.8.0"
[[dependencies]]
[[constraint]]
name = "github.com/sdboyer/deptestdos"
revision = "a0196baa11ea047dd65037287451d36b861b00ea"

Просмотреть файл

@ -1,11 +1,11 @@
[[dependencies]]
[[constraint]]
name = "github.com/not/used"
version = "2.0.0"
[[dependencies]]
[[constraint]]
name = "github.com/sdboyer/deptest"
version = "^0.8.0"
[[dependencies]]
[[constraint]]
name = "github.com/sdboyer/deptestdos"
revision = "a0196baa11ea047dd65037287451d36b861b00ea"

8
cmd/dep/testdata/harness_tests/remove/specific/case1/final/Gopkg.lock сгенерированный поставляемый
Просмотреть файл

@ -1,6 +1,5 @@
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
memo = "722f8e1427ab6d4dd1bc92376e4ce41ba6034a74e283a3fe4d65c7c838c7e0d2"
[[projects]]
name = "github.com/sdboyer/deptest"
@ -12,3 +11,10 @@ memo = "722f8e1427ab6d4dd1bc92376e4ce41ba6034a74e283a3fe4d65c7c838c7e0d2"
name = "github.com/sdboyer/deptestdos"
packages = ["."]
revision = "a0196baa11ea047dd65037287451d36b861b00ea"
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
inputs-digest = "722f8e1427ab6d4dd1bc92376e4ce41ba6034a74e283a3fe4d65c7c838c7e0d2"
solver-name = "gps-cdcl"
solver-version = 1

Просмотреть файл

@ -1,11 +1,11 @@
[[dependencies]]
[[constraint]]
name = "github.com/not/used"
version = "2.0.0"
[[dependencies]]
[[constraint]]
name = "github.com/sdboyer/deptest"
version = "^0.8.0"
[[dependencies]]
[[constraint]]
name = "github.com/sdboyer/deptestdos"
revision = "a0196baa11ea047dd65037287451d36b861b00ea"

Просмотреть файл

@ -1,11 +1,11 @@
[[dependencies]]
[[constraint]]
name = "github.com/not/used"
version = "2.0.0"
[[dependencies]]
[[constraint]]
name = "github.com/sdboyer/deptest"
version = "^0.8.0"
[[dependencies]]
[[constraint]]
name = "github.com/sdboyer/deptestdos"
revision = "a0196baa11ea047dd65037287451d36b861b00ea"

8
cmd/dep/testdata/harness_tests/remove/specific/case2/final/Gopkg.lock сгенерированный поставляемый
Просмотреть файл

@ -1,9 +1,15 @@
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
memo = "e7725ea56516a42a641aaaf5d48754258d9f3c59949cb8a0e8a21b1ab6e07179"
[[projects]]
name = "github.com/sdboyer/deptest"
packages = ["."]
revision = "ff2948a2ac8f538c4ecd55962e919d1e13e74baf"
version = "v1.0.0"
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
inputs-digest = "e7725ea56516a42a641aaaf5d48754258d9f3c59949cb8a0e8a21b1ab6e07179"
solver-name = "gps-cdcl"
solver-version = 1

Просмотреть файл

@ -1,11 +1,11 @@
[[dependencies]]
[[constraint]]
name = "github.com/not/used"
version = "2.0.0"
[[dependencies]]
[[constraint]]
name = "github.com/sdboyer/deptest"
version = "^0.8.0"
[[dependencies]]
[[constraint]]
name = "github.com/sdboyer/deptestdos"
revision = "a0196baa11ea047dd65037287451d36b861b00ea"

Просмотреть файл

@ -1,11 +1,11 @@
[[dependencies]]
[[constraint]]
name = "github.com/not/used"
version = "2.0.0"
[[dependencies]]
[[constraint]]
name = "github.com/sdboyer/deptest"
version = "^0.8.0"
[[dependencies]]
[[constraint]]
name = "github.com/sdboyer/deptestdos"
revision = "a0196baa11ea047dd65037287451d36b861b00ea"

8
cmd/dep/testdata/harness_tests/remove/unused/case1/final/Gopkg.lock сгенерированный поставляемый
Просмотреть файл

@ -1,6 +1,5 @@
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
memo = "722f8e1427ab6d4dd1bc92376e4ce41ba6034a74e283a3fe4d65c7c838c7e0d2"
[[projects]]
name = "github.com/sdboyer/deptest"
@ -12,3 +11,10 @@ memo = "722f8e1427ab6d4dd1bc92376e4ce41ba6034a74e283a3fe4d65c7c838c7e0d2"
name = "github.com/sdboyer/deptestdos"
packages = ["."]
revision = "a0196baa11ea047dd65037287451d36b861b00ea"
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
inputs-digest = "722f8e1427ab6d4dd1bc92376e4ce41ba6034a74e283a3fe4d65c7c838c7e0d2"
solver-name = "gps-cdcl"
solver-version = 1

Просмотреть файл

@ -1,11 +1,11 @@
[[dependencies]]
[[constraint]]
name = "github.com/not/used"
version = "2.0.0"
[[dependencies]]
[[constraint]]
name = "github.com/sdboyer/deptest"
version = "^0.8.0"
[[dependencies]]
[[constraint]]
name = "github.com/sdboyer/deptestdos"
revision = "a0196baa11ea047dd65037287451d36b861b00ea"

Просмотреть файл

@ -1,11 +1,11 @@
[[dependencies]]
[[constraint]]
name = "github.com/not/used"
version = "2.0.0"
[[dependencies]]
[[constraint]]
name = "github.com/sdboyer/deptest"
version = "^0.8.0"
[[dependencies]]
[[constraint]]
name = "github.com/sdboyer/deptestdos"
revision = "a0196baa11ea047dd65037287451d36b861b00ea"

8
cmd/dep/testdata/harness_tests/status/case1/dot/final/Gopkg.lock сгенерированный поставляемый
Просмотреть файл

@ -1,6 +1,5 @@
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
memo = "1b381263a360eafafe3ef7f9be626672668d17250a3c9a8debd169d1b5e2eebb"
[[projects]]
name = "github.com/sdboyer/deptest"
@ -13,3 +12,10 @@ memo = "1b381263a360eafafe3ef7f9be626672668d17250a3c9a8debd169d1b5e2eebb"
packages = ["."]
revision = "5c607206be5decd28e6263ffffdcee067266015e"
version = "v2.0.0"
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
inputs-digest = "1b381263a360eafafe3ef7f9be626672668d17250a3c9a8debd169d1b5e2eebb"
solver-name = "gps-cdcl"
solver-version = 1

Просмотреть файл

@ -1,3 +1,3 @@
[[dependencies]]
[[constraint]]
name = "github.com/sdboyer/deptest"
version = "^0.8.0"

Просмотреть файл

@ -1,3 +1,3 @@
[[dependencies]]
[[constraint]]
name = "github.com/sdboyer/deptest"
version = "^0.8.0"

8
cmd/dep/testdata/harness_tests/status/case1/json/final/Gopkg.lock сгенерированный поставляемый
Просмотреть файл

@ -1,6 +1,5 @@
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
memo = "1b381263a360eafafe3ef7f9be626672668d17250a3c9a8debd169d1b5e2eebb"
[[projects]]
name = "github.com/sdboyer/deptest"
@ -13,3 +12,10 @@ memo = "1b381263a360eafafe3ef7f9be626672668d17250a3c9a8debd169d1b5e2eebb"
packages = ["."]
revision = "5c607206be5decd28e6263ffffdcee067266015e"
version = "v2.0.0"
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
inputs-digest = "1b381263a360eafafe3ef7f9be626672668d17250a3c9a8debd169d1b5e2eebb"
solver-name = "gps-cdcl"
solver-version = 1

Просмотреть файл

@ -1,3 +1,3 @@
[[dependencies]]
[[constraint]]
name = "github.com/sdboyer/deptest"
version = "^0.8.0"

Просмотреть файл

@ -1,3 +1,3 @@
[[dependencies]]
[[constraint]]
name = "github.com/sdboyer/deptest"
version = "^0.8.0"

8
cmd/dep/testdata/harness_tests/status/case1/table/final/Gopkg.lock сгенерированный поставляемый
Просмотреть файл

@ -1,6 +1,5 @@
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
memo = "1b381263a360eafafe3ef7f9be626672668d17250a3c9a8debd169d1b5e2eebb"
[[projects]]
name = "github.com/sdboyer/deptest"
@ -13,3 +12,10 @@ memo = "1b381263a360eafafe3ef7f9be626672668d17250a3c9a8debd169d1b5e2eebb"
packages = ["."]
revision = "5c607206be5decd28e6263ffffdcee067266015e"
version = "v2.0.0"
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
inputs-digest = "1b381263a360eafafe3ef7f9be626672668d17250a3c9a8debd169d1b5e2eebb"
solver-name = "gps-cdcl"
solver-version = 1

Просмотреть файл

@ -1,3 +1,3 @@
[[dependencies]]
[[constraint]]
name = "github.com/sdboyer/deptest"
version = "^0.8.0"

Просмотреть файл

@ -1,3 +1,3 @@
[[dependencies]]
[[constraint]]
name = "github.com/sdboyer/deptest"
version = "^0.8.0"

Просмотреть файл

@ -1,7 +1,4 @@
[[dependencies]]
[[constraint]]
branch = "master"
name = "github.com/sdboyer/deptest"
[[dependencies]]
name = "github.com/sdboyer/deptestdos"

Просмотреть файл

@ -282,7 +282,7 @@ func TestLoadProjectManifestParseError(t *testing.T) {
tg.TempDir("src")
tg.TempDir("src/test1")
tg.TempFile(filepath.Join("src/test1", ManifestName), `[[dependencies]]`)
tg.TempFile(filepath.Join("src/test1", ManifestName), `[[constraint]]`)
tg.TempFile(filepath.Join("src/test1", LockName), `memo = "cdafe8641b28cd16fe025df278b0a49b9416859345d8b6ba0ace0272b74925ee"\n\n[[projects]]`)
tg.Setenv("GOPATH", tg.Path("."))
@ -308,7 +308,7 @@ func TestLoadProjectLockParseError(t *testing.T) {
tg.TempDir("src")
tg.TempDir("src/test1")
tg.TempFile(filepath.Join("src/test1", ManifestName), `[[dependencies]]`)
tg.TempFile(filepath.Join("src/test1", ManifestName), `[[constraint]]`)
tg.TempFile(filepath.Join("src/test1", LockName), `memo = "cdafe8641b28cd16fe025df278b0a49b9416859345d8b6ba0ace0272b74925ee"\n\n[[projects]]`)
tg.Setenv("GOPATH", tg.Path("."))
@ -333,7 +333,7 @@ func TestLoadProjectNoSrcDir(t *testing.T) {
defer tg.Cleanup()
tg.TempDir("test1")
tg.TempFile(filepath.Join("test1", ManifestName), `[[dependencies]]`)
tg.TempFile(filepath.Join("test1", ManifestName), `[[constraint]]`)
tg.TempFile(filepath.Join("test1", LockName), `memo = "cdafe8641b28cd16fe025df278b0a49b9416859345d8b6ba0ace0272b74925ee"\n\n[[projects]]`)
tg.Setenv("GOPATH", tg.Path("."))
@ -362,7 +362,7 @@ func TestCaseInsentitiveGOPATH(t *testing.T) {
h.TempDir("src")
h.TempDir("src/test1")
h.TempFile(filepath.Join("src/test1", ManifestName), `[[dependencies]]`)
h.TempFile(filepath.Join("src/test1", ManifestName), `[[constraint]]`)
// Shuffle letter case
rs := []rune(strings.ToLower(h.Path(".")))

Просмотреть файл

@ -674,6 +674,28 @@ func TestSemverConstraintOps(t *testing.T) {
}
}
func TestSemverConstraint_ImpliedCaret(t *testing.T) {
c, _ := NewSemverConstraintIC("1.0.0")
wantS := "^1.0.0"
gotS := c.String()
if wantS != gotS {
t.Errorf("Expected string %s, got %s", wantS, gotS)
}
wantI := "1.0.0"
gotI := c.ImpliedCaretString()
if wantI != gotI {
t.Errorf("Expected implied string %s, got %s", wantI, gotI)
}
wantT := "svc-^1.0.0"
gotT := c.typedString()
if wantT != gotT {
t.Errorf("Expected type string %s, got %s", wantT, gotT)
}
}
// Test that certain types of cross-version comparisons work when they are
// expressed as a version union (but that others don't).
func TestVersionUnion(t *testing.T) {

Просмотреть файл

@ -25,6 +25,14 @@ var (
type Constraint interface {
fmt.Stringer
// ImpliedCaretString converts the Constraint to a string in the same manner
// as String(), but treats the empty operator as equivalent to ^, rather
// than =.
//
// In the same way that String() is the inverse of NewConstraint(), this
// method is the inverse of NewSemverConstraintIC().
ImpliedCaretString() string
// Matches indicates if the provided Version is allowed by the Constraint.
Matches(Version) bool
@ -64,6 +72,26 @@ func NewSemverConstraint(body string) (Constraint, error) {
return semverConstraint{c: c}, nil
}
// NewSemverConstraintIC attempts to construct a semver Constraint object from the
// input string, defaulting to a caret, ^, when no operator is specified. Put
// differently, ^ is the default operator for NewSemverConstraintIC, while =
// is the default operator for NewSemverConstraint.
//
// If the input string cannot be made into a valid semver Constraint, an error
// is returned.
func NewSemverConstraintIC(body string) (Constraint, error) {
c, err := semver.NewConstraintIC(body)
if err != nil {
return nil, err
}
// If we got a simple semver.Version, simplify by returning our
// corresponding type
if sv, ok := c.(semver.Version); ok {
return semVersion{sv: sv}, nil
}
return semverConstraint{c: c}, nil
}
type semverConstraint struct {
c semver.Constraint
}
@ -72,6 +100,16 @@ func (c semverConstraint) String() string {
return c.c.String()
}
// ImpliedCaretString converts the Constraint to a string in the same manner
// as String(), but treats the empty operator as equivalent to ^, rather
// than =.
//
// In the same way that String() is the inverse of NewConstraint(), this
// method is the inverse of NewSemverConstraintIC().
func (c semverConstraint) ImpliedCaretString() string {
return c.c.ImpliedCaretString()
}
func (c semverConstraint) typedString() string {
return fmt.Sprintf("svc-%s", c.c.String())
}
@ -153,6 +191,10 @@ func (anyConstraint) String() string {
return "*"
}
func (anyConstraint) ImpliedCaretString() string {
return "*"
}
func (anyConstraint) typedString() string {
return "any-*"
}
@ -177,6 +219,10 @@ func (noneConstraint) String() string {
return ""
}
func (noneConstraint) ImpliedCaretString() string {
return ""
}
func (noneConstraint) typedString() string {
return "none-"
}

Просмотреть файл

@ -17,9 +17,6 @@ import (
// solution is all that would be necessary to constitute a lock file, though
// tools can include whatever other information they want in their storage.
type Lock interface {
// Indicates the version of the solver used to generate this lock data
//SolverVersion() string
// The hash of inputs to gps that resulted in this lock data
InputHash() []byte

Просмотреть файл

@ -14,6 +14,14 @@ import (
// additional methods that report information about the solve run.
type Solution interface {
Lock
// The name of the ProjectAnalyzer used in generating this solution.
AnalyzerName() string
// The version of the ProjectAnalyzer used in generating this solution.
AnalyzerVersion() int
// The name of the Solver used in generating this solution.
SolverName() string
// The version of the Solver used in generating this solution.
SolverVersion() int
Attempts() int
}
@ -26,6 +34,15 @@ type solution struct {
// The hash digest of the input opts
hd []byte
// The analyzer name
analyzerName string
// The analyzer version
analyzerVersion int
// The solver used in producing this solution
solv Solver
}
// WriteDepTree takes a basedir and a Lock, and exports all the projects
@ -76,3 +93,19 @@ func (r solution) Attempts() int {
func (r solution) InputHash() []byte {
return r.hd
}
func (r solution) AnalyzerName() string {
return r.analyzerName
}
func (r solution) AnalyzerVersion() int {
return r.analyzerVersion
}
func (r solution) SolverName() string {
return r.solv.Name()
}
func (r solution) SolverVersion() int {
return r.solv.Version()
}

Просмотреть файл

@ -34,6 +34,7 @@ func init() {
}, nil),
},
}
basicResult.analyzerName, basicResult.analyzerVersion = (naiveAnalyzer{}).Info()
// Just in case something needs punishing, kubernetes offers a complex,
// real-world set of dependencies, and this revision is known to work.

Просмотреть файл

@ -328,6 +328,49 @@ type Solver interface {
// Solve initiates a solving run. It will either complete successfully with
// a Solution, or fail with an informative error.
Solve() (Solution, error)
// Name returns a string identifying the particular solver backend.
//
// Different solvers likely have different invariants, and likely will not
// have identical possible result sets for any particular inputs; in some
// cases, they may even be disjoint.
Name() string
// Version returns an int indicating the version of the solver of the given
// Name(). Implementations should change their reported version ONLY when
// the logic is changed in such a way that substantially changes the result
// set that is possible for a substantial subset of likely inputs.
//
// "Substantial" is an imprecise term, and it is used intentionally. There
// are no easy, general ways of subdividing constraint solving problems such
// that one can know, a priori, the full impact that subtle algorithmic
// changes will have on possible result sets. Consequently, we have to fall
// back on coarser, intuition-based reasoning as to whether a change is
// large enough that it is likely to be broadly user-visible.
//
// This is acceptable, because this value is not used programmatically by
// the solver in any way. Rather, it is intend for implementing tools to
// use as a coarse signal to users about compatibility between their tool's
// version and the current data, typically via persistence to a Lock.
// Changes to the version number reported should be weighed between
// confusing teams by having two members' tools continuously rolling back
// each others' chosen Solutions for no apparent reason, and annoying teams
// by changing the number for changes so remote that warnings about solver
// version mismatches become meaningless.
//
// Err on the side of caution.
//
// Chronology is the only implication of the ordering - that lower version
// numbers were published before higher numbers.
Version() int
}
func (s *solver) Name() string {
return "gps-cdcl"
}
func (s *solver) Version() int {
return 1
}
// Solve attempts to find a dependency solution for the given project, as
@ -352,8 +395,9 @@ func (s *solver) Solve() (Solution, error) {
if err == nil {
soln = solution{
att: s.attempts,
solv: s,
}
soln.analyzerName, soln.analyzerVersion = s.rd.an.Info()
soln.hd = s.HashInputs()
// Convert ProjectAtoms into LockedProjects

Просмотреть файл

@ -119,6 +119,10 @@ func (r Revision) String() string {
return string(r)
}
func (r Revision) ImpliedCaretString() string {
return r.String()
}
func (r Revision) typedString() string {
return "r-" + string(r)
}
@ -195,6 +199,10 @@ func (v branchVersion) String() string {
return string(v.name)
}
func (v branchVersion) ImpliedCaretString() string {
return v.String()
}
func (v branchVersion) typedString() string {
return fmt.Sprintf("b-%s", v.String())
}
@ -272,6 +280,10 @@ func (v plainVersion) String() string {
return string(v)
}
func (v plainVersion) ImpliedCaretString() string {
return v.String()
}
func (v plainVersion) typedString() string {
return fmt.Sprintf("pv-%s", v.String())
}
@ -355,6 +367,10 @@ func (v semVersion) String() string {
return str
}
func (v semVersion) ImpliedCaretString() string {
return v.sv.ImpliedCaretString()
}
func (v semVersion) typedString() string {
return fmt.Sprintf("sv-%s", v.String())
}
@ -439,6 +455,10 @@ func (v versionPair) String() string {
return v.v.String()
}
func (v versionPair) ImpliedCaretString() string {
return v.v.ImpliedCaretString()
}
func (v versionPair) typedString() string {
return fmt.Sprintf("%s-%s", v.Unpair().typedString(), v.Underlying().typedString())
}

Просмотреть файл

@ -184,6 +184,13 @@ func (vtu versionTypeUnion) String() string {
panic("versionTypeUnion should never be turned into a string; it is solver internal-only")
}
// This should generally not be called, but is required for the interface. If it
// is called, we have a bigger problem (the type has escaped the solver); thus,
// panic.
func (vtu versionTypeUnion) ImpliedCaretString() string {
panic("versionTypeUnion should never be turned into a string; it is solver internal-only")
}
func (vtu versionTypeUnion) typedString() string {
panic("versionTypeUnion should never be turned into a string; it is solver internal-only")
}

Просмотреть файл

@ -145,7 +145,7 @@ func (tc *IntegrationTestCase) CompareOutput(stdout string) {
stdout = normalizeLines(stdout)
if expStr != stdout {
tc.t.Errorf("expected: %q but got: %q", expStr, stdout)
tc.t.Errorf("(WNT):\n%s\n(GOT):\n%s\n", expStr, stdout)
}
}

62
lock.go
Просмотреть файл

@ -18,15 +18,31 @@ import (
const LockName = "Gopkg.lock"
type Lock struct {
Memo []byte
SolveMeta SolveMeta
P []gps.LockedProject
}
type SolveMeta struct {
InputsDigest []byte
AnalyzerName string
AnalyzerVersion int
SolverName string
SolverVersion int
}
type rawLock struct {
Memo string `toml:"memo"`
SolveMeta solveMeta `toml:"solve-meta"`
Projects []rawLockedProject `toml:"projects"`
}
type solveMeta struct {
InputsDigest string `toml:"inputs-digest"`
AnalyzerName string `toml:"analyzer-name"`
AnalyzerVersion int `toml:"analyzer-version"`
SolverName string `toml:"solver-name"`
SolverVersion int `toml:"solver-version"`
}
type rawLockedProject struct {
Name string `toml:"name"`
Branch string `toml:"branch,omitempty"`
@ -58,11 +74,16 @@ func fromRawLock(raw rawLock) (*Lock, error) {
P: make([]gps.LockedProject, len(raw.Projects)),
}
l.Memo, err = hex.DecodeString(raw.Memo)
l.SolveMeta.InputsDigest, err = hex.DecodeString(raw.SolveMeta.InputsDigest)
if err != nil {
return nil, errors.Errorf("invalid hash digest in lock's memo field")
}
l.SolveMeta.AnalyzerName = raw.SolveMeta.AnalyzerName
l.SolveMeta.AnalyzerVersion = raw.SolveMeta.AnalyzerVersion
l.SolveMeta.SolverName = raw.SolveMeta.SolverName
l.SolveMeta.SolverVersion = raw.SolveMeta.SolverVersion
for i, ld := range raw.Projects {
r := gps.Revision(ld.Revision)
@ -84,11 +105,12 @@ func fromRawLock(raw rawLock) (*Lock, error) {
}
l.P[i] = gps.NewLockedProject(id, v, ld.Packages)
}
return l, nil
}
func (l *Lock) InputHash() []byte {
return l.Memo
return l.SolveMeta.InputsDigest
}
func (l *Lock) Projects() []gps.LockedProject {
@ -98,7 +120,13 @@ func (l *Lock) Projects() []gps.LockedProject {
// toRaw converts the manifest into a representation suitable to write to the lock file
func (l *Lock) toRaw() rawLock {
raw := rawLock{
Memo: hex.EncodeToString(l.Memo),
SolveMeta: solveMeta{
InputsDigest: hex.EncodeToString(l.SolveMeta.InputsDigest),
AnalyzerName: l.SolveMeta.AnalyzerName,
AnalyzerVersion: l.SolveMeta.AnalyzerVersion,
SolverName: l.SolveMeta.SolverName,
SolverVersion: l.SolveMeta.SolverVersion,
},
Projects: make([]rawLockedProject, len(l.P)),
}
@ -129,29 +157,25 @@ func (l *Lock) MarshalTOML() ([]byte, error) {
return result, errors.Wrap(err, "Unable to marshal lock to TOML string")
}
// LockFromInterface converts an arbitrary gps.Lock to dep's representation of a
// lock. If the input is already dep's *lock, the input is returned directly.
// LockFromSolution converts a gps.Solution to dep's representation of a lock.
//
// Data is defensively copied wherever necessary to ensure the resulting *lock
// shares no memory with the original lock.
//
// As gps.Solution is a superset of gps.Lock, this can also be used to convert
// solutions to dep's lock format.
func LockFromInterface(in gps.Lock) *Lock {
if in == nil {
return nil
} else if l, ok := in.(*Lock); ok {
return l
}
func LockFromSolution(in gps.Solution) *Lock {
h, p := in.InputHash(), in.Projects()
l := &Lock{
Memo: make([]byte, len(h)),
SolveMeta: SolveMeta{
InputsDigest: make([]byte, len(h)),
AnalyzerName: in.AnalyzerName(),
AnalyzerVersion: in.AnalyzerVersion(),
SolverName: in.SolverName(),
SolverVersion: in.SolverVersion(),
},
P: make([]gps.LockedProject, len(p)),
}
copy(l.Memo, h)
copy(l.SolveMeta.InputsDigest, h)
copy(l.P, p)
return l
}

Просмотреть файл

@ -28,7 +28,9 @@ func TestReadLock(t *testing.T) {
b, _ := hex.DecodeString("2252a285ab27944a4d7adcba8dbd03980f59ba652f12db39fa93b927c345593e")
want := &Lock{
Memo: b,
SolveMeta: SolveMeta{
InputsDigest: b,
},
P: []gps.LockedProject{
gps.NewLockedProject(
gps.ProjectIdentifier{ProjectRoot: gps.ProjectRoot("github.com/golang/dep/internal/gps")},
@ -52,7 +54,9 @@ func TestReadLock(t *testing.T) {
b, _ = hex.DecodeString("2252a285ab27944a4d7adcba8dbd03980f59ba652f12db39fa93b927c345593e")
want = &Lock{
Memo: b,
SolveMeta: SolveMeta{
InputsDigest: b,
},
P: []gps.LockedProject{
gps.NewLockedProject(
gps.ProjectIdentifier{ProjectRoot: gps.ProjectRoot("github.com/golang/dep/internal/gps")},
@ -75,7 +79,9 @@ func TestWriteLock(t *testing.T) {
want := h.GetTestFileString(golden)
memo, _ := hex.DecodeString("2252a285ab27944a4d7adcba8dbd03980f59ba652f12db39fa93b927c345593e")
l := &Lock{
Memo: memo,
SolveMeta: SolveMeta{
InputsDigest: memo,
},
P: []gps.LockedProject{
gps.NewLockedProject(
gps.ProjectIdentifier{ProjectRoot: gps.ProjectRoot("github.com/golang/dep/internal/gps")},
@ -104,7 +110,9 @@ func TestWriteLock(t *testing.T) {
want = h.GetTestFileString(golden)
memo, _ = hex.DecodeString("2252a285ab27944a4d7adcba8dbd03980f59ba652f12db39fa93b927c345593e")
l = &Lock{
Memo: memo,
SolveMeta: SolveMeta{
InputsDigest: memo,
},
P: []gps.LockedProject{
gps.NewLockedProject(
gps.ProjectIdentifier{ProjectRoot: gps.ProjectRoot("github.com/golang/dep/internal/gps")},

Просмотреть файл

@ -19,15 +19,15 @@ import (
const ManifestName = "Gopkg.toml"
type Manifest struct {
Dependencies gps.ProjectConstraints
Constraints gps.ProjectConstraints
Ovr gps.ProjectConstraints
Ignored []string
Required []string
}
type rawManifest struct {
Dependencies []rawProject `toml:"dependencies,omitempty"`
Overrides []rawProject `toml:"overrides,omitempty"`
Constraints []rawProject `toml:"constraint,omitempty"`
Overrides []rawProject `toml:"override,omitempty"`
Ignored []string `toml:"ignored,omitempty"`
Required []string `toml:"required,omitempty"`
}
@ -58,7 +58,7 @@ func validateManifest(s string) ([]error, error) {
if reflect.TypeOf(val).Kind() != reflect.Map {
errs = append(errs, errors.New("metadata should be a TOML table"))
}
case "dependencies", "overrides":
case "constraint", "override":
// Invalid if type assertion fails. Not a TOML array of tables.
if rawProj, ok := val.([]interface{}); ok {
// Iterate through each array of tables
@ -117,21 +117,21 @@ func readManifest(r io.Reader) (*Manifest, []error, error) {
func fromRawManifest(raw rawManifest) (*Manifest, error) {
m := &Manifest{
Dependencies: make(gps.ProjectConstraints, len(raw.Dependencies)),
Constraints: make(gps.ProjectConstraints, len(raw.Constraints)),
Ovr: make(gps.ProjectConstraints, len(raw.Overrides)),
Ignored: raw.Ignored,
Required: raw.Required,
}
for i := 0; i < len(raw.Dependencies); i++ {
name, prj, err := toProject(raw.Dependencies[i])
for i := 0; i < len(raw.Constraints); i++ {
name, prj, err := toProject(raw.Constraints[i])
if err != nil {
return nil, err
}
if _, exists := m.Dependencies[name]; exists {
if _, exists := m.Constraints[name]; exists {
return nil, errors.Errorf("multiple dependencies specified for %s, can only specify one", name)
}
m.Dependencies[name] = prj
m.Constraints[name] = prj
}
for i := 0; i < len(raw.Overrides); i++ {
@ -162,7 +162,7 @@ func toProject(raw rawProject) (n gps.ProjectRoot, pp gps.ProjectProperties, err
}
// always semver if we can
pp.Constraint, err = gps.NewSemverConstraint(raw.Version)
pp.Constraint, err = gps.NewSemverConstraintIC(raw.Version)
if err != nil {
// but if not, fall back on plain versions
pp.Constraint = gps.NewVersion(raw.Version)
@ -182,15 +182,15 @@ func toProject(raw rawProject) (n gps.ProjectRoot, pp gps.ProjectProperties, err
// toRaw converts the manifest into a representation suitable to write to the manifest file
func (m *Manifest) toRaw() rawManifest {
raw := rawManifest{
Dependencies: make([]rawProject, 0, len(m.Dependencies)),
Constraints: make([]rawProject, 0, len(m.Constraints)),
Overrides: make([]rawProject, 0, len(m.Ovr)),
Ignored: m.Ignored,
Required: m.Required,
}
for n, prj := range m.Dependencies {
raw.Dependencies = append(raw.Dependencies, toRawProject(n, prj))
for n, prj := range m.Constraints {
raw.Constraints = append(raw.Constraints, toRawProject(n, prj))
}
sort.Sort(sortedRawProjects(raw.Dependencies))
sort.Sort(sortedRawProjects(raw.Constraints))
for n, prj := range m.Ovr {
raw.Overrides = append(raw.Overrides, toRawProject(n, prj))
@ -236,7 +236,7 @@ func toRawProject(name gps.ProjectRoot, project gps.ProjectProperties) rawProjec
case gps.IsBranch:
raw.Branch = v.String()
case gps.IsSemver, gps.IsVersion:
raw.Version = v.String()
raw.Version = v.ImpliedCaretString()
}
return raw
}
@ -248,13 +248,13 @@ func toRawProject(name gps.ProjectRoot, project gps.ProjectProperties) rawProjec
// if !gps.IsAny(pp.Constraint) && !gps.IsNone(pp.Constraint) {
if !gps.IsAny(project.Constraint) && project.Constraint != nil {
// Has to be a semver range.
raw.Version = project.Constraint.String()
raw.Version = project.Constraint.ImpliedCaretString()
}
return raw
}
func (m *Manifest) DependencyConstraints() gps.ProjectConstraints {
return m.Dependencies
return m.Constraints
}
func (m *Manifest) TestDependencyConstraints() gps.ProjectConstraints {

Просмотреть файл

@ -25,9 +25,9 @@ func TestReadManifest(t *testing.T) {
t.Fatalf("Should have read Manifest correctly, but got err %q", err)
}
c, _ := gps.NewSemverConstraint(">=0.12.0, <1.0.0")
c, _ := gps.NewSemverConstraint("^0.12.0")
want := Manifest{
Dependencies: map[gps.ProjectRoot]gps.ProjectProperties{
Constraints: map[gps.ProjectRoot]gps.ProjectProperties{
gps.ProjectRoot("github.com/golang/dep/internal/gps"): {
Constraint: c,
},
@ -44,7 +44,7 @@ func TestReadManifest(t *testing.T) {
Ignored: []string{"github.com/foo/bar"},
}
if !reflect.DeepEqual(got.Dependencies, want.Dependencies) {
if !reflect.DeepEqual(got.Constraints, want.Constraints) {
t.Error("Valid manifest's dependencies did not parse as expected")
}
if !reflect.DeepEqual(got.Ovr, want.Ovr) {
@ -61,9 +61,9 @@ func TestWriteManifest(t *testing.T) {
golden := "manifest/golden.toml"
want := h.GetTestFileString(golden)
c, _ := gps.NewSemverConstraint(">=0.12.0, <1.0.0")
c, _ := gps.NewSemverConstraint("^0.12.0")
m := &Manifest{
Dependencies: map[gps.ProjectRoot]gps.ProjectProperties{
Constraints: map[gps.ProjectRoot]gps.ProjectProperties{
gps.ProjectRoot("github.com/golang/dep/internal/gps"): {
Constraint: c,
},
@ -128,7 +128,7 @@ func TestValidateManifest(t *testing.T) {
}{
{
tomlString: `
[[dependencies]]
[[constraint]]
name = "github.com/foo/bar"
`,
want: []error{},
@ -149,7 +149,7 @@ func TestValidateManifest(t *testing.T) {
[[bar]]
author = "xyz"
[[dependencies]]
[[constraint]]
name = "github.com/foo/bar"
version = ""
`,
@ -163,45 +163,45 @@ func TestValidateManifest(t *testing.T) {
tomlString: `
metadata = "project-name"
[[dependencies]]
[[constraint]]
name = "github.com/foo/bar"
`,
want: []error{errors.New("metadata should be a TOML table")},
},
{
tomlString: `
dependencies = "foo"
overrides = "bar"
constraint = "foo"
override = "bar"
`,
want: []error{
errors.New("dependencies should be a TOML array of tables"),
errors.New("overrides should be a TOML array of tables"),
errors.New("constraint should be a TOML array of tables"),
errors.New("override should be a TOML array of tables"),
},
},
{
tomlString: `
[[dependencies]]
[[constraint]]
name = "github.com/foo/bar"
location = "some-value"
link = "some-other-value"
metadata = "foo"
[[overrides]]
[[override]]
nick = "foo"
`,
want: []error{
errors.New("Invalid key \"location\" in \"dependencies\""),
errors.New("Invalid key \"link\" in \"dependencies\""),
errors.New("Invalid key \"nick\" in \"overrides\""),
errors.New("metadata in \"dependencies\" should be a TOML table"),
errors.New("Invalid key \"location\" in \"constraint\""),
errors.New("Invalid key \"link\" in \"constraint\""),
errors.New("Invalid key \"nick\" in \"override\""),
errors.New("metadata in \"constraint\" should be a TOML table"),
},
},
{
tomlString: `
[[dependencies]]
[[constraint]]
name = "github.com/foo/bar"
[dependencies.metadata]
[constraint.metadata]
color = "blue"
`,
want: []error{},

4
testdata/analyzer/Gopkg.toml поставляемый
Просмотреть файл

@ -1,8 +1,8 @@
[[dependencies]]
[[constraint]]
name = "github.com/golang/dep/internal/gps"
version = ">=0.12.0, <1.0.0"
[[dependencies]]
[[constraint]]
name = "github.com/pkg/errors"
version = ">=0.8.0, <1.0.0"

3
testdata/lock/error0.toml поставляемый
Просмотреть файл

@ -1,4 +1,5 @@
memo = "2252a285ab27944a4d7adcba8dbd03980f59ba652f12db39fa93b927c345593e"
[solve-meta]
inputs-digest = "2252a285ab27944a4d7adcba8dbd03980f59ba652f12db39fa93b927c345593e"
[[projects]]
name = "github.com/golang/dep/internal/gps"

6
testdata/lock/error1.toml поставляемый
Просмотреть файл

@ -1,7 +1,9 @@
memo = "000aaa2a285ab27944a4d7adcba8dbd03980f59ba652f12db39fa93b927c345593e"
[[projects]]
name = "github.com/golang/dep/internal/gps"
branch = "master"
revision = "d05d5aca9f895d19e9265839bffeadd74a2d2ecb"
packages = ["."]
[solve-meta]
inputs-digest = "000aaa2a285ab27944a4d7adcba8dbd03980f59ba652f12db39fa93b927c345593e"

6
testdata/lock/error2.toml поставляемый
Просмотреть файл

@ -1,5 +1,7 @@
memo = "2252a285ab27944a4d7adcba8dbd03980f59ba652f12db39fa93b927c345593e"
[[projects]]
name = "github.com/golang/dep/internal/gps"
packages = ["."]
[solve-meta]
inputs-digest = "2252a285ab27944a4d7adcba8dbd03980f59ba652f12db39fa93b927c345593e"

8
testdata/lock/golden0.toml поставляемый
Просмотреть файл

@ -1,7 +1,13 @@
memo = "2252a285ab27944a4d7adcba8dbd03980f59ba652f12db39fa93b927c345593e"
[[projects]]
branch = "master"
name = "github.com/golang/dep/internal/gps"
packages = ["."]
revision = "d05d5aca9f895d19e9265839bffeadd74a2d2ecb"
[solve-meta]
analyzer-name = ""
analyzer-version = 0
inputs-digest = "2252a285ab27944a4d7adcba8dbd03980f59ba652f12db39fa93b927c345593e"
solver-name = ""
solver-version = 0

8
testdata/lock/golden1.toml поставляемый
Просмотреть файл

@ -1,7 +1,13 @@
memo = "2252a285ab27944a4d7adcba8dbd03980f59ba652f12db39fa93b927c345593e"
[[projects]]
name = "github.com/golang/dep/internal/gps"
packages = ["."]
revision = "d05d5aca9f895d19e9265839bffeadd74a2d2ecb"
version = "0.12.2"
[solve-meta]
analyzer-name = ""
analyzer-version = 0
inputs-digest = "2252a285ab27944a4d7adcba8dbd03980f59ba652f12db39fa93b927c345593e"
solver-name = ""
solver-version = 0

4
testdata/manifest/error1.toml поставляемый
Просмотреть файл

@ -1,13 +1,13 @@
ignored = ["github.com/foo/bar"]
[[dependencies]]
[[constraint]]
name = "github.com/golang/dep/internal/gps"
branch = "master"
revision = "d05d5aca9f895d19e9265839bffeadd74a2d2ecb"
version = "^v0.12.0"
source = "https://github.com/golang/dep/internal/gps"
[[overrides]]
[[override]]
name = "github.com/golang/dep/internal/gps"
branch = "master"
revision = "d05d5aca9f895d19e9265839bffeadd74a2d2ecb"

4
testdata/manifest/error2.toml поставляемый
Просмотреть файл

@ -1,9 +1,9 @@
ignored = ["github.com/foo/bar"]
[[dependencies]]
[[constraint]]
name = "github.com/golang/dep/internal/gps"
branch = "master"
[[dependencies]]
[[constraint]]
name = "github.com/golang/dep/internal/gps"
branch = "master"

8
testdata/manifest/golden.toml поставляемый
Просмотреть файл

@ -1,14 +1,14 @@
ignored = ["github.com/foo/bar"]
[[dependencies]]
[[constraint]]
name = "github.com/babble/brook"
revision = "d05d5aca9f895d19e9265839bffeadd74a2d2ecb"
[[dependencies]]
[[constraint]]
name = "github.com/golang/dep/internal/gps"
version = ">=0.12.0, <1.0.0"
version = "0.12.0"
[[overrides]]
[[override]]
branch = "master"
name = "github.com/golang/dep/internal/gps"
source = "https://github.com/golang/dep/internal/gps"

8
testdata/txn_writer/expected_lock.toml поставляемый
Просмотреть файл

@ -1,9 +1,15 @@
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
memo = "595716d270828e763c811ef79c9c41f85b1d1bfbdfe85280036405c03772206c"
[[projects]]
name = "github.com/sdboyer/dep-test"
packages = ["."]
revision = "2a3a211e171803acb82d1d5d42ceb53228f51751"
version = "1.0.0"
[solve-meta]
analyzer-name = ""
analyzer-version = 0
inputs-digest = "595716d270828e763c811ef79c9c41f85b1d1bfbdfe85280036405c03772206c"
solver-name = ""
solver-version = 0

15
testdata/txn_writer/expected_manifest.toml поставляемый
Просмотреть файл

@ -19,9 +19,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"
#
@ -41,12 +42,12 @@
# system1-data = "value that is used by a system"
# system2-data = "value that is used by another system"
## Overrides have the same structure as [[dependencies]], but supersede all
## [[dependencies]] declarations from all projects. Only the current project's
## [[overrides]] are applied.
## Overrides have the same structure as [[constraint]], but supersede all
## [[constraint]] declarations from all projects. Only [[override]] from
## the current project's are applied.
##
## Overrides are a sledgehammer. Use them only as a last resort.
# [[overrides]]
# [[override]]
## Required: the root import path of the project being constrained.
# name = "github.com/user/project"
#
@ -65,6 +66,6 @@
[[dependencies]]
[[constraint]]
name = "github.com/sdboyer/dep-test"
version = "1.0.0"

3
testdata/txn_writer/original_lock.toml поставляемый
Просмотреть файл

@ -1,4 +1,5 @@
memo = "595716d270828e763c811ef79c9c41f85b1d1bfbdfe85280036405c03772206c"
[solve-meta]
inputs-digest = "595716d270828e763c811ef79c9c41f85b1d1bfbdfe85280036405c03772206c"
[[projects]]
name = "github.com/foo/bar"

3
testdata/txn_writer/updated_lock.toml поставляемый
Просмотреть файл

@ -1,4 +1,5 @@
memo = "2252a285ab27944a4d7adcba8dbd03980f59ba652f12db39fa93b927c345593e"
[solve-meta]
inputs-digest = "2252a285ab27944a4d7adcba8dbd03980f59ba652f12db39fa93b927c345593e"
[[projects]]
name = "github.com/foo/bar"

Просмотреть файл

@ -44,9 +44,10 @@ var exampleTOML = []byte(`
## 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"
#
@ -66,12 +67,12 @@ var exampleTOML = []byte(`
# system1-data = "value that is used by a system"
# system2-data = "value that is used by another system"
## Overrides have the same structure as [[dependencies]], but supersede all
## [[dependencies]] declarations from all projects. Only the current project's
## [[overrides]] are applied.
## Overrides have the same structure as [[constraint]], but supersede all
## [[constraint]] declarations from all projects. Only [[override]] from
## the current project's are applied.
##
## Overrides are a sledgehammer. Use them only as a last resort.
# [[overrides]]
# [[override]]
## Required: the root import path of the project being constrained.
# name = "github.com/user/project"
#

Просмотреть файл

@ -261,18 +261,18 @@ func TestSafeWriter_ModifiedLock(t *testing.T) {
originalLock := new(Lock)
*originalLock = *pc.Project.Lock
originalLock.Memo = []byte{} // zero out the input hash to ensure non-equivalency
originalLock.SolveMeta.InputsDigest = []byte{} // zero out the input hash to ensure non-equivalency
sw, _ := NewSafeWriter(nil, originalLock, pc.Project.Lock, VendorOnChanged)
// Verify prepared actions
if sw.HasManifest() {
t.Fatal("Did not expect the payload to contain the manifest")
t.Fatal("Did not expect the manifest to be written")
}
if !sw.HasLock() {
t.Fatal("Expected the payload to contain the lock")
t.Fatal("Expected that the writer should plan to write the lock")
}
if !sw.writeVendor {
t.Fatal("Expected the payload to contain the vendor directory")
t.Fatal("Expected that the writer should plan to write the vendor directory")
}
// Write changes
@ -308,7 +308,7 @@ func TestSafeWriter_ModifiedLockSkipVendor(t *testing.T) {
originalLock := new(Lock)
*originalLock = *pc.Project.Lock
originalLock.Memo = []byte{} // zero out the input hash to ensure non-equivalency
originalLock.SolveMeta.InputsDigest = []byte{} // zero out the input hash to ensure non-equivalency
sw, _ := NewSafeWriter(nil, originalLock, pc.Project.Lock, VendorNever)
// Verify prepared actions