Skip to content
This repository was archived by the owner on Sep 9, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cmd/dep/ensure.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
}

Expand Down Expand Up @@ -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)
}

Expand Down
14 changes: 7 additions & 7 deletions internal/gps/lock.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}

Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -209,7 +209,7 @@ type safeLock struct {
p []LockedProject
}

func (sl safeLock) InputHash() []byte {
func (sl safeLock) InputsDigest() []byte {
return sl.h
}

Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions internal/gps/lockdiff.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/gps/result.go → internal/gps/solution.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
4 changes: 2 additions & 2 deletions internal/gps/solve_basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

Expand All @@ -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")
}

Expand Down
2 changes: 1 addition & 1 deletion internal/gps/source_cache_bolt_encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
6 changes: 3 additions & 3 deletions lock.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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{
Expand Down