зеркало из https://github.com/golang/dep.git
Incorporate lock split-up into integration branch
Conflicts: cmd/dep/testdata/harness_tests/init/case1/final/Gopkg.lock cmd/dep/testdata/harness_tests/init/case2/final/Gopkg.lock cmd/dep/testdata/harness_tests/remove/force/case1/final/Gopkg.lock cmd/dep/testdata/harness_tests/remove/specific/case1/final/Gopkg.lock cmd/dep/testdata/harness_tests/remove/specific/case2/final/Gopkg.lock cmd/dep/testdata/harness_tests/remove/unused/case1/final/Gopkg.lock cmd/dep/testdata/harness_tests/status/case1/dot/final/Gopkg.lock cmd/dep/testdata/harness_tests/status/case1/json/final/Gopkg.lock cmd/dep/testdata/harness_tests/status/case1/table/final/Gopkg.lock txn_writer_test.go
This commit is contained in:
Коммит
f6c2b15106
|
@ -162,7 +162,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
|
||||
|
|
|
@ -184,7 +184,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 and log feedback for all the new projects.
|
||||
|
@ -217,7 +217,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"))
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
|
||||
|
|
|
@ -176,7 +176,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 {
|
||||
|
|
|
@ -277,7 +277,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.
|
||||
|
|
|
@ -1,7 +1,13 @@
|
|||
memo = "14b07b05e0f01051b03887ab2bf80b516bc5510ea92f75f76c894b1745d8850c"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/sdboyer/deptest"
|
||||
packages = ["."]
|
||||
revision = "ff2948a2ac8f538c4ecd55962e919d1e13e74baf"
|
||||
version = "v1.0.0"
|
||||
|
||||
[solve-meta]
|
||||
analyzer-name = "dep"
|
||||
analyzer-version = 1
|
||||
inputs-hash = "14b07b05e0f01051b03887ab2bf80b516bc5510ea92f75f76c894b1745d8850c"
|
||||
solver-name = "gps-cdcl"
|
||||
solver-version = 1
|
||||
|
|
|
@ -1,7 +1,13 @@
|
|||
memo = "e7725ea56516a42a641aaaf5d48754258d9f3c59949cb8a0e8a21b1ab6e07179"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/sdboyer/deptest"
|
||||
packages = ["."]
|
||||
revision = "ff2948a2ac8f538c4ecd55962e919d1e13e74baf"
|
||||
version = "v1.0.0"
|
||||
|
||||
[solve-meta]
|
||||
analyzer-name = "dep"
|
||||
analyzer-version = 1
|
||||
inputs-hash = "e7725ea56516a42a641aaaf5d48754258d9f3c59949cb8a0e8a21b1ab6e07179"
|
||||
solver-name = "gps-cdcl"
|
||||
solver-version = 1
|
||||
|
|
|
@ -1,7 +1,13 @@
|
|||
memo = "e5c16e09ed6f0a1a2b3cf472c34b7fd50861dd070e81d5e623f72e8173f0c065"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/sdboyer/deptest"
|
||||
packages = ["."]
|
||||
revision = "3f4c3bea144e112a69bbe5d8d01c1b09a544253f"
|
||||
|
||||
[solve-meta]
|
||||
analyzer-name = "dep"
|
||||
analyzer-version = 1
|
||||
inputs-hash = "e5c16e09ed6f0a1a2b3cf472c34b7fd50861dd070e81d5e623f72e8173f0c065"
|
||||
solver-name = "gps-cdcl"
|
||||
solver-version = 1
|
||||
|
|
8
cmd/dep/testdata/harness_tests/ensure/override/case1/final/Gopkg.lock
сгенерированный
поставляемый
8
cmd/dep/testdata/harness_tests/ensure/override/case1/final/Gopkg.lock
сгенерированный
поставляемый
|
@ -1,7 +1,13 @@
|
|||
memo = "8bca9526e654e56e05d9075d1f33fa5b649bf6d58aa7d71ca39e7fbea8468e07"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/sdboyer/deptest"
|
||||
packages = ["."]
|
||||
revision = "ff2948a2ac8f538c4ecd55962e919d1e13e74baf"
|
||||
version = "v1.0.0"
|
||||
|
||||
[solve-meta]
|
||||
analyzer-name = "dep"
|
||||
analyzer-version = 1
|
||||
inputs-hash = "8bca9526e654e56e05d9075d1f33fa5b649bf6d58aa7d71ca39e7fbea8468e07"
|
||||
solver-name = "gps-cdcl"
|
||||
solver-version = 1
|
||||
|
|
8
cmd/dep/testdata/harness_tests/ensure/pkg-errors/case1/final/Gopkg.lock
сгенерированный
поставляемый
8
cmd/dep/testdata/harness_tests/ensure/pkg-errors/case1/final/Gopkg.lock
сгенерированный
поставляемый
|
@ -1 +1,7 @@
|
|||
memo = "ab4fef131ee828e96ba67d31a7d690bd5f2f42040c6766b1b12fe856f87e0ff7"
|
||||
|
||||
[solve-meta]
|
||||
analyzer-name = "dep"
|
||||
analyzer-version = 1
|
||||
inputs-hash = "ab4fef131ee828e96ba67d31a7d690bd5f2f42040c6766b1b12fe856f87e0ff7"
|
||||
solver-name = "gps-cdcl"
|
||||
solver-version = 1
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
memo = "1b381263a360eafafe3ef7f9be626672668d17250a3c9a8debd169d1b5e2eebb"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/sdboyer/deptest"
|
||||
|
@ -11,3 +10,10 @@ memo = "1b381263a360eafafe3ef7f9be626672668d17250a3c9a8debd169d1b5e2eebb"
|
|||
packages = ["."]
|
||||
revision = "5c607206be5decd28e6263ffffdcee067266015e"
|
||||
version = "v2.0.0"
|
||||
|
||||
[solve-meta]
|
||||
analyzer-name = "dep"
|
||||
analyzer-version = 1
|
||||
inputs-hash = "1b381263a360eafafe3ef7f9be626672668d17250a3c9a8debd169d1b5e2eebb"
|
||||
solver-name = "gps-cdcl"
|
||||
solver-version = 1
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
memo = "1b381263a360eafafe3ef7f9be626672668d17250a3c9a8debd169d1b5e2eebb"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/sdboyer/deptest"
|
||||
|
@ -10,3 +9,10 @@ memo = "1b381263a360eafafe3ef7f9be626672668d17250a3c9a8debd169d1b5e2eebb"
|
|||
name = "github.com/sdboyer/deptestdos"
|
||||
packages = ["."]
|
||||
revision = "a0196baa11ea047dd65037287451d36b861b00ea"
|
||||
|
||||
[solve-meta]
|
||||
analyzer-name = "dep"
|
||||
analyzer-version = 1
|
||||
inputs-hash = "1b381263a360eafafe3ef7f9be626672668d17250a3c9a8debd169d1b5e2eebb"
|
||||
solver-name = "gps-cdcl"
|
||||
solver-version = 1
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
memo = "ced51326ad990b11098d8076d0f7d72d89eee1ba6e8dacc7bc73be05cddac438"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/sdboyer/deptest"
|
||||
|
@ -11,3 +10,10 @@ memo = "ced51326ad990b11098d8076d0f7d72d89eee1ba6e8dacc7bc73be05cddac438"
|
|||
packages = ["."]
|
||||
revision = "5c607206be5decd28e6263ffffdcee067266015e"
|
||||
version = "v2.0.0"
|
||||
|
||||
[solve-meta]
|
||||
analyzer-name = "dep"
|
||||
analyzer-version = 1
|
||||
inputs-hash = "ced51326ad990b11098d8076d0f7d72d89eee1ba6e8dacc7bc73be05cddac438"
|
||||
solver-name = "gps-cdcl"
|
||||
solver-version = 1
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
memo = "af9a783a5430dabcaaf44683c09e2b729e1c0d61f13bfdf6677c4fd0b41387ca"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
|
@ -10,3 +9,10 @@ memo = "af9a783a5430dabcaaf44683c09e2b729e1c0d61f13bfdf6677c4fd0b41387ca"
|
|||
name = "github.com/sdboyer/deptestdos"
|
||||
packages = ["."]
|
||||
revision = "a0196baa11ea047dd65037287451d36b861b00ea"
|
||||
|
||||
[solve-meta]
|
||||
analyzer-name = "dep"
|
||||
analyzer-version = 1
|
||||
inputs-hash = "af9a783a5430dabcaaf44683c09e2b729e1c0d61f13bfdf6677c4fd0b41387ca"
|
||||
solver-name = "gps-cdcl"
|
||||
solver-version = 1
|
||||
|
|
|
@ -1,7 +1,13 @@
|
|||
memo = "14b07b05e0f01051b03887ab2bf80b516bc5510ea92f75f76c894b1745d8850c"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/sdboyer/deptest"
|
||||
packages = ["."]
|
||||
revision = "ff2948a2ac8f538c4ecd55962e919d1e13e74baf"
|
||||
version = "v1.0.0"
|
||||
|
||||
[solve-meta]
|
||||
analyzer-name = "dep"
|
||||
analyzer-version = 1
|
||||
inputs-hash = "14b07b05e0f01051b03887ab2bf80b516bc5510ea92f75f76c894b1745d8850c"
|
||||
solver-name = "gps-cdcl"
|
||||
solver-version = 1
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
memo = "1b381263a360eafafe3ef7f9be626672668d17250a3c9a8debd169d1b5e2eebb"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/sdboyer/deptest"
|
||||
|
@ -11,3 +10,10 @@ memo = "1b381263a360eafafe3ef7f9be626672668d17250a3c9a8debd169d1b5e2eebb"
|
|||
packages = ["."]
|
||||
revision = "5c607206be5decd28e6263ffffdcee067266015e"
|
||||
version = "v2.0.0"
|
||||
|
||||
[solve-meta]
|
||||
analyzer-name = "dep"
|
||||
analyzer-version = 1
|
||||
inputs-hash = "1b381263a360eafafe3ef7f9be626672668d17250a3c9a8debd169d1b5e2eebb"
|
||||
solver-name = "gps-cdcl"
|
||||
solver-version = 1
|
||||
|
|
8
cmd/dep/testdata/harness_tests/remove/specific/case1/final/Gopkg.lock
сгенерированный
поставляемый
8
cmd/dep/testdata/harness_tests/remove/specific/case1/final/Gopkg.lock
сгенерированный
поставляемый
|
@ -1,4 +1,3 @@
|
|||
memo = "722f8e1427ab6d4dd1bc92376e4ce41ba6034a74e283a3fe4d65c7c838c7e0d2"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/sdboyer/deptest"
|
||||
|
@ -10,3 +9,10 @@ memo = "722f8e1427ab6d4dd1bc92376e4ce41ba6034a74e283a3fe4d65c7c838c7e0d2"
|
|||
name = "github.com/sdboyer/deptestdos"
|
||||
packages = ["."]
|
||||
revision = "a0196baa11ea047dd65037287451d36b861b00ea"
|
||||
|
||||
[solve-meta]
|
||||
analyzer-name = "dep"
|
||||
analyzer-version = 1
|
||||
inputs-hash = "722f8e1427ab6d4dd1bc92376e4ce41ba6034a74e283a3fe4d65c7c838c7e0d2"
|
||||
solver-name = "gps-cdcl"
|
||||
solver-version = 1
|
||||
|
|
8
cmd/dep/testdata/harness_tests/remove/specific/case2/final/Gopkg.lock
сгенерированный
поставляемый
8
cmd/dep/testdata/harness_tests/remove/specific/case2/final/Gopkg.lock
сгенерированный
поставляемый
|
@ -1,7 +1,13 @@
|
|||
memo = "e7725ea56516a42a641aaaf5d48754258d9f3c59949cb8a0e8a21b1ab6e07179"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/sdboyer/deptest"
|
||||
packages = ["."]
|
||||
revision = "ff2948a2ac8f538c4ecd55962e919d1e13e74baf"
|
||||
version = "v1.0.0"
|
||||
|
||||
[solve-meta]
|
||||
analyzer-name = "dep"
|
||||
analyzer-version = 1
|
||||
inputs-hash = "e7725ea56516a42a641aaaf5d48754258d9f3c59949cb8a0e8a21b1ab6e07179"
|
||||
solver-name = "gps-cdcl"
|
||||
solver-version = 1
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
memo = "722f8e1427ab6d4dd1bc92376e4ce41ba6034a74e283a3fe4d65c7c838c7e0d2"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/sdboyer/deptest"
|
||||
|
@ -10,3 +9,10 @@ memo = "722f8e1427ab6d4dd1bc92376e4ce41ba6034a74e283a3fe4d65c7c838c7e0d2"
|
|||
name = "github.com/sdboyer/deptestdos"
|
||||
packages = ["."]
|
||||
revision = "a0196baa11ea047dd65037287451d36b861b00ea"
|
||||
|
||||
[solve-meta]
|
||||
analyzer-name = "dep"
|
||||
analyzer-version = 1
|
||||
inputs-hash = "722f8e1427ab6d4dd1bc92376e4ce41ba6034a74e283a3fe4d65c7c838c7e0d2"
|
||||
solver-name = "gps-cdcl"
|
||||
solver-version = 1
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
memo = "1b381263a360eafafe3ef7f9be626672668d17250a3c9a8debd169d1b5e2eebb"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/sdboyer/deptest"
|
||||
|
@ -11,3 +10,10 @@ memo = "1b381263a360eafafe3ef7f9be626672668d17250a3c9a8debd169d1b5e2eebb"
|
|||
packages = ["."]
|
||||
revision = "5c607206be5decd28e6263ffffdcee067266015e"
|
||||
version = "v2.0.0"
|
||||
|
||||
[solve-meta]
|
||||
analyzer-name = "dep"
|
||||
analyzer-version = 1
|
||||
inputs-hash = "1b381263a360eafafe3ef7f9be626672668d17250a3c9a8debd169d1b5e2eebb"
|
||||
solver-name = "gps-cdcl"
|
||||
solver-version = 1
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
memo = "1b381263a360eafafe3ef7f9be626672668d17250a3c9a8debd169d1b5e2eebb"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/sdboyer/deptest"
|
||||
|
@ -11,3 +10,10 @@ memo = "1b381263a360eafafe3ef7f9be626672668d17250a3c9a8debd169d1b5e2eebb"
|
|||
packages = ["."]
|
||||
revision = "5c607206be5decd28e6263ffffdcee067266015e"
|
||||
version = "v2.0.0"
|
||||
|
||||
[solve-meta]
|
||||
analyzer-name = "dep"
|
||||
analyzer-version = 1
|
||||
inputs-hash = "1b381263a360eafafe3ef7f9be626672668d17250a3c9a8debd169d1b5e2eebb"
|
||||
solver-name = "gps-cdcl"
|
||||
solver-version = 1
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
memo = "1b381263a360eafafe3ef7f9be626672668d17250a3c9a8debd169d1b5e2eebb"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/sdboyer/deptest"
|
||||
|
@ -11,3 +10,10 @@ memo = "1b381263a360eafafe3ef7f9be626672668d17250a3c9a8debd169d1b5e2eebb"
|
|||
packages = ["."]
|
||||
revision = "5c607206be5decd28e6263ffffdcee067266015e"
|
||||
version = "v2.0.0"
|
||||
|
||||
[solve-meta]
|
||||
analyzer-name = "dep"
|
||||
analyzer-version = 1
|
||||
inputs-hash = "1b381263a360eafafe3ef7f9be626672668d17250a3c9a8debd169d1b5e2eebb"
|
||||
solver-name = "gps-cdcl"
|
||||
solver-version = 1
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ func init() {
|
|||
}, nil),
|
||||
},
|
||||
}
|
||||
basicResult.analyzerName, basicResult.analyzerVersion = (naiveAnalyzer{}).Info()
|
||||
|
||||
// just in case something needs punishing, kubernetes is happy to oblige
|
||||
kub = atom{
|
||||
|
|
|
@ -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
|
||||
|
@ -351,9 +394,10 @@ func (s *solver) Solve() (Solution, error) {
|
|||
var soln solution
|
||||
if err == nil {
|
||||
soln = solution{
|
||||
att: s.attempts,
|
||||
att: s.attempts,
|
||||
solv: s,
|
||||
}
|
||||
|
||||
soln.analyzerName, soln.analyzerVersion = s.rd.an.Info()
|
||||
soln.hd = s.HashInputs()
|
||||
|
||||
// Convert ProjectAtoms into LockedProjects
|
||||
|
|
68
lock.go
68
lock.go
|
@ -18,13 +18,29 @@ import (
|
|||
const LockName = "Gopkg.lock"
|
||||
|
||||
type Lock struct {
|
||||
Memo []byte
|
||||
P []gps.LockedProject
|
||||
SolveMeta SolveMeta
|
||||
P []gps.LockedProject
|
||||
}
|
||||
|
||||
type SolveMeta struct {
|
||||
Memo []byte
|
||||
AnalyzerName string
|
||||
AnalyzerVersion int
|
||||
SolverName string
|
||||
SolverVersion int
|
||||
}
|
||||
|
||||
type rawLock struct {
|
||||
Memo string `toml:"memo"`
|
||||
Projects []rawLockedProject `toml:"projects"`
|
||||
SolveMeta solveMeta `toml:"solve-meta"`
|
||||
Projects []rawLockedProject `toml:"projects"`
|
||||
}
|
||||
|
||||
type solveMeta struct {
|
||||
Memo string `toml:"inputs-hash"`
|
||||
AnalyzerName string `toml:"analyzer-name"`
|
||||
AnalyzerVersion int `toml:"analyzer-version"`
|
||||
SolverName string `toml:"solver-name"`
|
||||
SolverVersion int `toml:"solver-version"`
|
||||
}
|
||||
|
||||
type rawLockedProject struct {
|
||||
|
@ -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.Memo, err = hex.DecodeString(raw.SolveMeta.Memo)
|
||||
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.Memo
|
||||
}
|
||||
|
||||
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{
|
||||
Memo: hex.EncodeToString(l.SolveMeta.Memo),
|
||||
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)),
|
||||
P: make([]gps.LockedProject, len(p)),
|
||||
SolveMeta: SolveMeta{
|
||||
Memo: 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.Memo, h)
|
||||
copy(l.P, p)
|
||||
return l
|
||||
}
|
||||
|
|
16
lock_test.go
16
lock_test.go
|
@ -28,7 +28,9 @@ func TestReadLock(t *testing.T) {
|
|||
|
||||
b, _ := hex.DecodeString("2252a285ab27944a4d7adcba8dbd03980f59ba652f12db39fa93b927c345593e")
|
||||
want := &Lock{
|
||||
Memo: b,
|
||||
SolveMeta: SolveMeta{
|
||||
Memo: 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{
|
||||
Memo: 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{
|
||||
Memo: 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{
|
||||
Memo: memo,
|
||||
},
|
||||
P: []gps.LockedProject{
|
||||
gps.NewLockedProject(
|
||||
gps.ProjectIdentifier{ProjectRoot: gps.ProjectRoot("github.com/golang/dep/internal/gps")},
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
memo = "2252a285ab27944a4d7adcba8dbd03980f59ba652f12db39fa93b927c345593e"
|
||||
[solve-meta]
|
||||
inputs-hash = "2252a285ab27944a4d7adcba8dbd03980f59ba652f12db39fa93b927c345593e"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/golang/dep/internal/gps"
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
memo = "000aaa2a285ab27944a4d7adcba8dbd03980f59ba652f12db39fa93b927c345593e"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/golang/dep/internal/gps"
|
||||
branch = "master"
|
||||
revision = "d05d5aca9f895d19e9265839bffeadd74a2d2ecb"
|
||||
packages = ["."]
|
||||
|
||||
[solve-meta]
|
||||
inputs-hash = "000aaa2a285ab27944a4d7adcba8dbd03980f59ba652f12db39fa93b927c345593e"
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
memo = "2252a285ab27944a4d7adcba8dbd03980f59ba652f12db39fa93b927c345593e"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/golang/dep/internal/gps"
|
||||
packages = ["."]
|
||||
|
||||
[solve-meta]
|
||||
inputs-hash = "2252a285ab27944a4d7adcba8dbd03980f59ba652f12db39fa93b927c345593e"
|
||||
|
||||
|
|
|
@ -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-hash = "2252a285ab27944a4d7adcba8dbd03980f59ba652f12db39fa93b927c345593e"
|
||||
solver-name = ""
|
||||
solver-version = 0
|
||||
|
|
|
@ -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-hash = "2252a285ab27944a4d7adcba8dbd03980f59ba652f12db39fa93b927c345593e"
|
||||
solver-name = ""
|
||||
solver-version = 0
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
Memo: 595716d270828e763c811ef79c9c41f85b1d1bfbdfe85280036405c03772206c -> 2252a285ab27944a4d7adcba8dbd03980f59ba652f12db39fa93b927c345593e
|
||||
|
||||
Add:
|
||||
[[projects]]
|
||||
name = "github.com/sdboyer/deptest"
|
||||
|
|
|
@ -1,7 +1,13 @@
|
|||
memo = "595716d270828e763c811ef79c9c41f85b1d1bfbdfe85280036405c03772206c"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/sdboyer/dep-test"
|
||||
packages = ["."]
|
||||
revision = "2a3a211e171803acb82d1d5d42ceb53228f51751"
|
||||
version = "1.0.0"
|
||||
|
||||
[solve-meta]
|
||||
analyzer-name = ""
|
||||
analyzer-version = 0
|
||||
inputs-hash = "595716d270828e763c811ef79c9c41f85b1d1bfbdfe85280036405c03772206c"
|
||||
solver-name = ""
|
||||
solver-version = 0
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
memo = "595716d270828e763c811ef79c9c41f85b1d1bfbdfe85280036405c03772206c"
|
||||
[solve-meta]
|
||||
inputs-hash = "595716d270828e763c811ef79c9c41f85b1d1bfbdfe85280036405c03772206c"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/foo/bar"
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
memo = "2252a285ab27944a4d7adcba8dbd03980f59ba652f12db39fa93b927c345593e"
|
||||
[solve-meta]
|
||||
inputs-hash = "595716d270828e763c811ef79c9c41f85b1d1bfbdfe85280036405c03772206c"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/foo/bar"
|
||||
|
|
|
@ -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.Memo = []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.Memo = []byte{} // zero out the input hash to ensure non-equivalency
|
||||
sw, _ := NewSafeWriter(nil, originalLock, pc.Project.Lock, VendorNever)
|
||||
|
||||
// Verify prepared actions
|
||||
|
|
Загрузка…
Ссылка в новой задаче