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

Commit a445d4d

Browse files
authored
Merge pull request #1229 from sdboyer/puppy-dog-tails
Rename Lock.InputHash()
2 parents 4cb413e + 453ac46 commit a445d4d

File tree

8 files changed

+19
-19
lines changed

8 files changed

+19
-19
lines changed

cmd/dep/ensure.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ func (cmd *ensureCommand) runDefault(ctx *dep.Ctx, args []string, p *dep.Project
234234
return errors.Wrap(err, "prepare solver")
235235
}
236236

237-
if p.Lock != nil && bytes.Equal(p.Lock.InputHash(), solver.HashInputs()) {
237+
if p.Lock != nil && bytes.Equal(p.Lock.InputsDigest(), solver.HashInputs()) {
238238
// Memo matches, so there's probably nothing to do.
239239
if ctx.Verbose {
240240
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,
340340
// user a bit, but the extra effort required is minimal, and it ensures the
341341
// user is isolating variables in the event of solve problems (was it the
342342
// "pending" changes, or the -update that caused the problem?).
343-
if !bytes.Equal(p.Lock.InputHash(), solver.HashInputs()) {
343+
if !bytes.Equal(p.Lock.InputsDigest(), solver.HashInputs()) {
344344
ctx.Out.Printf("Warning: %s is out of sync with %s or the project's imports.", dep.LockName, dep.ManifestName)
345345
}
346346

@@ -405,7 +405,7 @@ func (cmd *ensureCommand) runAdd(ctx *dep.Ctx, args []string, p *dep.Project, sm
405405
// user a bit, but the extra effort required is minimal, and it ensures the
406406
// user is isolating variables in the event of solve problems (was it the
407407
// "pending" changes, or the -add that caused the problem?).
408-
if p.Lock != nil && !bytes.Equal(p.Lock.InputHash(), solver.HashInputs()) {
408+
if p.Lock != nil && !bytes.Equal(p.Lock.InputsDigest(), solver.HashInputs()) {
409409
ctx.Out.Printf("Warning: %s is out of sync with %s or the project's imports.", dep.LockName, dep.ManifestName)
410410
}
411411

internal/gps/lock.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import (
1818
// solution is all that would be necessary to constitute a lock file, though
1919
// tools can include whatever other information they want in their storage.
2020
type Lock interface {
21-
// The hash of inputs to gps that resulted in this lock data
22-
InputHash() []byte
21+
// The hash digest of inputs to gps that resulted in this lock data.
22+
InputsDigest() []byte
2323

2424
// Projects returns the list of LockedProjects contained in the lock data.
2525
Projects() []LockedProject
@@ -30,7 +30,7 @@ type Lock interface {
3030
// parameter is true) whether the locks' input hashes are equal.
3131
func LocksAreEq(l1, l2 Lock, checkHash bool) bool {
3232
// Cheapest ops first
33-
if checkHash && !bytes.Equal(l1.InputHash(), l2.InputHash()) {
33+
if checkHash && !bytes.Equal(l1.InputsDigest(), l2.InputsDigest()) {
3434
return false
3535
}
3636

@@ -82,10 +82,10 @@ type SimpleLock []LockedProject
8282

8383
var _ Lock = SimpleLock{}
8484

85-
// InputHash always returns an empty string for SimpleLock. This makes it useless
85+
// InputsDigest always returns an empty string for SimpleLock. This makes it useless
8686
// as a stable lock to be written to disk, but still useful for some ephemeral
8787
// purposes.
88-
func (SimpleLock) InputHash() []byte {
88+
func (SimpleLock) InputsDigest() []byte {
8989
return nil
9090
}
9191

@@ -209,7 +209,7 @@ type safeLock struct {
209209
p []LockedProject
210210
}
211211

212-
func (sl safeLock) InputHash() []byte {
212+
func (sl safeLock) InputsDigest() []byte {
213213
return sl.h
214214
}
215215

@@ -226,7 +226,7 @@ func prepLock(l Lock) safeLock {
226226
pl := l.Projects()
227227

228228
rl := safeLock{
229-
h: l.InputHash(),
229+
h: l.InputsDigest(),
230230
p: make([]LockedProject, len(pl)),
231231
}
232232
copy(rl.p, pl)

internal/gps/lockdiff.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ func DiffLocks(l1 Lock, l2 Lock) *LockDiff {
7979

8080
diff := LockDiff{}
8181

82-
h1 := hex.EncodeToString(l1.InputHash())
83-
h2 := hex.EncodeToString(l2.InputHash())
82+
h1 := hex.EncodeToString(l1.InputsDigest())
83+
h2 := hex.EncodeToString(l2.InputsDigest())
8484
if h1 != h2 {
8585
diff.HashDiff = &StringDiff{Previous: h1, Current: h2}
8686
}

internal/gps/result.go renamed to internal/gps/solution.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ func (r solution) Attempts() int {
144144
return r.att
145145
}
146146

147-
func (r solution) InputHash() []byte {
147+
func (r solution) InputsDigest() []byte {
148148
return r.hd
149149
}
150150

File renamed without changes.

internal/gps/solve_basic_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1574,7 +1574,7 @@ func (ds depspec) DependencyConstraints() ProjectConstraints {
15741574
type fixLock []LockedProject
15751575

15761576
// impl Lock interface
1577-
func (fixLock) InputHash() []byte {
1577+
func (fixLock) InputsDigest() []byte {
15781578
return []byte("fooooorooooofooorooofoo")
15791579
}
15801580

@@ -1586,7 +1586,7 @@ func (l fixLock) Projects() []LockedProject {
15861586
type dummyLock struct{}
15871587

15881588
// impl Lock interface
1589-
func (dummyLock) InputHash() []byte {
1589+
func (dummyLock) InputsDigest() []byte {
15901590
return []byte("fooooorooooofooorooofoo")
15911591
}
15921592

internal/gps/source_cache_bolt_encode.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ func lockedProjectFromCache(m *pb.LockedProject) (LockedProject, error) {
278278
// cachePutLock stores the Lock as fields in the bolt.Bucket.
279279
func cachePutLock(b *bolt.Bucket, l Lock) error {
280280
// InputHash
281-
if v := l.InputHash(); len(v) > 0 {
281+
if v := l.InputsDigest(); len(v) > 0 {
282282
if err := b.Put(cacheKeyHash, v); err != nil {
283283
return errors.Wrap(err, "failed to put hash")
284284
}

lock.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ func fromRawLock(raw rawLock) (*Lock, error) {
112112
return l, nil
113113
}
114114

115-
// InputHash returns the hash of inputs which produced this lock data.
116-
func (l *Lock) InputHash() []byte {
115+
// InputsDigest returns the hash of inputs which produced this lock data.
116+
func (l *Lock) InputsDigest() []byte {
117117
return l.SolveMeta.InputsDigest
118118
}
119119

@@ -182,7 +182,7 @@ func (l *Lock) MarshalTOML() ([]byte, error) {
182182
// Data is defensively copied wherever necessary to ensure the resulting *lock
183183
// shares no memory with the original lock.
184184
func LockFromSolution(in gps.Solution) *Lock {
185-
h, p := in.InputHash(), in.Projects()
185+
h, p := in.InputsDigest(), in.Projects()
186186

187187
l := &Lock{
188188
SolveMeta: SolveMeta{

0 commit comments

Comments
 (0)