diff --git a/cmd/dep/ensure.go b/cmd/dep/ensure.go index a90c8da18d..ef35e7f069 100644 --- a/cmd/dep/ensure.go +++ b/cmd/dep/ensure.go @@ -234,7 +234,7 @@ func (cmd *ensureCommand) runDefault(ctx *dep.Ctx, args []string, p *dep.Project return errors.Wrap(err, "prepare solver") } - if p.Lock != nil && bytes.Equal(p.Lock.InputHash(), solver.HashInputs()) { + if p.Lock != nil && bytes.Equal(p.Lock.InputsDigest(), solver.HashInputs()) { // Memo matches, so there's probably nothing to do. if ctx.Verbose { ctx.Out.Printf("%s was already in sync with imports and %s\n", dep.LockName, dep.ManifestName) @@ -340,7 +340,7 @@ func (cmd *ensureCommand) runUpdate(ctx *dep.Ctx, args []string, p *dep.Project, // user a bit, but the extra effort required is minimal, and it ensures the // user is isolating variables in the event of solve problems (was it the // "pending" changes, or the -update that caused the problem?). - if !bytes.Equal(p.Lock.InputHash(), solver.HashInputs()) { + if !bytes.Equal(p.Lock.InputsDigest(), solver.HashInputs()) { ctx.Out.Printf("Warning: %s is out of sync with %s or the project's imports.", dep.LockName, dep.ManifestName) } @@ -405,7 +405,7 @@ func (cmd *ensureCommand) runAdd(ctx *dep.Ctx, args []string, p *dep.Project, sm // user a bit, but the extra effort required is minimal, and it ensures the // user is isolating variables in the event of solve problems (was it the // "pending" changes, or the -add that caused the problem?). - if p.Lock != nil && !bytes.Equal(p.Lock.InputHash(), solver.HashInputs()) { + if p.Lock != nil && !bytes.Equal(p.Lock.InputsDigest(), solver.HashInputs()) { ctx.Out.Printf("Warning: %s is out of sync with %s or the project's imports.", dep.LockName, dep.ManifestName) } diff --git a/internal/gps/lock.go b/internal/gps/lock.go index 3952c808e1..8b776213df 100644 --- a/internal/gps/lock.go +++ b/internal/gps/lock.go @@ -18,8 +18,8 @@ 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 { - // The hash of inputs to gps that resulted in this lock data - InputHash() []byte + // The hash digest of inputs to gps that resulted in this lock data. + InputsDigest() []byte // Projects returns the list of LockedProjects contained in the lock data. Projects() []LockedProject @@ -30,7 +30,7 @@ type Lock interface { // parameter is true) whether the locks' input hashes are equal. func LocksAreEq(l1, l2 Lock, checkHash bool) bool { // Cheapest ops first - if checkHash && !bytes.Equal(l1.InputHash(), l2.InputHash()) { + if checkHash && !bytes.Equal(l1.InputsDigest(), l2.InputsDigest()) { return false } @@ -82,10 +82,10 @@ type SimpleLock []LockedProject var _ Lock = SimpleLock{} -// InputHash always returns an empty string for SimpleLock. This makes it useless +// InputsDigest always returns an empty string for SimpleLock. This makes it useless // as a stable lock to be written to disk, but still useful for some ephemeral // purposes. -func (SimpleLock) InputHash() []byte { +func (SimpleLock) InputsDigest() []byte { return nil } @@ -209,7 +209,7 @@ type safeLock struct { p []LockedProject } -func (sl safeLock) InputHash() []byte { +func (sl safeLock) InputsDigest() []byte { return sl.h } @@ -226,7 +226,7 @@ func prepLock(l Lock) safeLock { pl := l.Projects() rl := safeLock{ - h: l.InputHash(), + h: l.InputsDigest(), p: make([]LockedProject, len(pl)), } copy(rl.p, pl) diff --git a/internal/gps/lockdiff.go b/internal/gps/lockdiff.go index b695486dea..839b49c5e5 100644 --- a/internal/gps/lockdiff.go +++ b/internal/gps/lockdiff.go @@ -79,8 +79,8 @@ func DiffLocks(l1 Lock, l2 Lock) *LockDiff { diff := LockDiff{} - h1 := hex.EncodeToString(l1.InputHash()) - h2 := hex.EncodeToString(l2.InputHash()) + h1 := hex.EncodeToString(l1.InputsDigest()) + h2 := hex.EncodeToString(l2.InputsDigest()) if h1 != h2 { diff.HashDiff = &StringDiff{Previous: h1, Current: h2} } diff --git a/internal/gps/result.go b/internal/gps/solution.go similarity index 98% rename from internal/gps/result.go rename to internal/gps/solution.go index 4179f0d687..2422caabe6 100644 --- a/internal/gps/result.go +++ b/internal/gps/solution.go @@ -144,7 +144,7 @@ func (r solution) Attempts() int { return r.att } -func (r solution) InputHash() []byte { +func (r solution) InputsDigest() []byte { return r.hd } diff --git a/internal/gps/result_test.go b/internal/gps/solution_test.go similarity index 100% rename from internal/gps/result_test.go rename to internal/gps/solution_test.go diff --git a/internal/gps/solve_basic_test.go b/internal/gps/solve_basic_test.go index 066dc35b34..1936487718 100644 --- a/internal/gps/solve_basic_test.go +++ b/internal/gps/solve_basic_test.go @@ -1574,7 +1574,7 @@ func (ds depspec) DependencyConstraints() ProjectConstraints { type fixLock []LockedProject // impl Lock interface -func (fixLock) InputHash() []byte { +func (fixLock) InputsDigest() []byte { return []byte("fooooorooooofooorooofoo") } @@ -1586,7 +1586,7 @@ func (l fixLock) Projects() []LockedProject { type dummyLock struct{} // impl Lock interface -func (dummyLock) InputHash() []byte { +func (dummyLock) InputsDigest() []byte { return []byte("fooooorooooofooorooofoo") } diff --git a/internal/gps/source_cache_bolt_encode.go b/internal/gps/source_cache_bolt_encode.go index 7d685aa988..c00513afed 100644 --- a/internal/gps/source_cache_bolt_encode.go +++ b/internal/gps/source_cache_bolt_encode.go @@ -278,7 +278,7 @@ func lockedProjectFromCache(m *pb.LockedProject) (LockedProject, error) { // cachePutLock stores the Lock as fields in the bolt.Bucket. func cachePutLock(b *bolt.Bucket, l Lock) error { // InputHash - if v := l.InputHash(); len(v) > 0 { + if v := l.InputsDigest(); len(v) > 0 { if err := b.Put(cacheKeyHash, v); err != nil { return errors.Wrap(err, "failed to put hash") } diff --git a/lock.go b/lock.go index f9c9b88253..e11e9839a4 100644 --- a/lock.go +++ b/lock.go @@ -112,8 +112,8 @@ func fromRawLock(raw rawLock) (*Lock, error) { return l, nil } -// InputHash returns the hash of inputs which produced this lock data. -func (l *Lock) InputHash() []byte { +// InputsDigest returns the hash of inputs which produced this lock data. +func (l *Lock) InputsDigest() []byte { return l.SolveMeta.InputsDigest } @@ -182,7 +182,7 @@ func (l *Lock) MarshalTOML() ([]byte, error) { // Data is defensively copied wherever necessary to ensure the resulting *lock // shares no memory with the original lock. func LockFromSolution(in gps.Solution) *Lock { - h, p := in.InputHash(), in.Projects() + h, p := in.InputsDigest(), in.Projects() l := &Lock{ SolveMeta: SolveMeta{