From a329ae4882bda16f328751db117a85358f1e1577 Mon Sep 17 00:00:00 2001 From: sam boyer Date: Thu, 30 Jun 2016 22:03:11 -0400 Subject: [PATCH] Add ignores to input hashing --- analysis.go | 2 +- hash.go | 17 ++++++++++++++++- hash_test.go | 6 +++++- solve_basic_test.go | 5 ----- 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/analysis.go b/analysis.go index 977e4533..b91d2a5e 100644 --- a/analysis.go +++ b/analysis.go @@ -46,7 +46,7 @@ func init() { // fileRoot = "/home/user/go/src/github.com/foo/bar" // importRoot = "github.com/foo/bar" // -// Where the fileRoot and importRoot align. However, if you provide: +// where the fileRoot and importRoot align. However, if you provide: // // fileRoot = "/home/user/workspace/path/to/repo" // importRoot = "github.com/foo/bar" diff --git a/hash.go b/hash.go index e4aa2457..073edf46 100644 --- a/hash.go +++ b/hash.go @@ -72,9 +72,24 @@ func (s *solver) HashInputs() ([]byte, error) { } } + // Add the package ignores, if any. + if len(s.args.Ignore) > 0 { + // Dump and sort the ignores + ig := make([]string, len(s.args.Ignore)) + k := 0 + for pkg := range s.args.Ignore { + ig[k] = pkg + k++ + } + sort.Strings(ig) + + for _, igp := range ig { + h.Write([]byte(igp)) + } + } + // TODO overrides // TODO aliases - // TODO ignores return h.Sum(nil), nil } diff --git a/hash_test.go b/hash_test.go index b67fd815..606664ec 100644 --- a/hash_test.go +++ b/hash_test.go @@ -13,6 +13,10 @@ func TestHashInputs(t *testing.T) { Root: string(fix.ds[0].Name()), Name: fix.ds[0].Name(), Manifest: fix.ds[0], + Ignore: map[string]bool{ + "foo": true, + "bar": true, + }, } // prep a fixture-overridden solver @@ -33,7 +37,7 @@ func TestHashInputs(t *testing.T) { } h := sha256.New() - for _, v := range []string{"a", "a", "1.0.0", "b", "b", "1.0.0", stdlibPkgs, "root", "", "root", "a", "b"} { + for _, v := range []string{"a", "a", "1.0.0", "b", "b", "1.0.0", stdlibPkgs, "root", "", "root", "a", "b", "bar", "foo"} { h.Write([]byte(v)) } correct := h.Sum(nil) diff --git a/solve_basic_test.go b/solve_basic_test.go index d3c0171f..ea377422 100644 --- a/solve_basic_test.go +++ b/solve_basic_test.go @@ -998,7 +998,6 @@ func (b *depspecBridge) computeRootReach() ([]string, error) { return nil, err } - //pruneIgnoredPackages(ptree, dsm.ignore()) return ptree.ListExternalImports(true, true, dsm.ignore()) } @@ -1014,10 +1013,6 @@ func (b *depspecBridge) verifyRoot(path string) error { func (b *depspecBridge) listPackages(id ProjectIdentifier, v Version) (PackageTree, error) { return b.sm.(fixSM).ListPackages(b.key(id), v) - //if err == nil { - //pruneIgnoredPackages(ptree, dsm.ignore()) - //} - //return ptree, err } // override deduceRemoteRepo on bridge to make all our pkg/project mappings work