Skip to content
This repository has been archived by the owner on Feb 3, 2018. It is now read-only.

Commit

Permalink
Add root pkgs to HashInputs()
Browse files Browse the repository at this point in the history
...sorta. Gotta encapsulate this so that tests can swap out the impl.
  • Loading branch information
sdboyer committed Jun 21, 2016
1 parent f4d9d53 commit 46031eb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
19 changes: 18 additions & 1 deletion hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,24 @@ func (o SolveOpts) HashInputs() []byte {
// in the hash.
h.Write([]byte(stdlibPkgs))

// TODO static analysis
// TODO deal with an err here
ptree, _ := listPackages(o.Root, string(o.N))
for _, perr := range ptree.Packages {
if perr.Err != nil {
h.Write([]byte(perr.Err.Error()))
} else {
h.Write([]byte(perr.P.Name))
h.Write([]byte(perr.P.CommentPath))
h.Write([]byte(perr.P.ImportPath))
for _, imp := range perr.P.Imports {
h.Write([]byte(imp))
}
for _, imp := range perr.P.TestImports {
h.Write([]byte(imp))
}
}
}

// TODO overrides
// TODO aliases
// TODO ignores
Expand Down
1 change: 1 addition & 0 deletions hash_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ func TestHashInputs(t *testing.T) {
dig := opts.HashInputs()

h := sha256.New()
//for _, v := range []string{"a", "a", "1.0.0", "b", "b", "1.0.0", "root", "", "root", "a", "b"} {
for _, v := range []string{"a", "a", "1.0.0", "b", "b", "1.0.0"} {
h.Write([]byte(v))
}
Expand Down

0 comments on commit 46031eb

Please sign in to comment.