From b45b275b99df46918a709c73655e9cbca02cd7d1 Mon Sep 17 00:00:00 2001 From: Alan Donovan Date: Tue, 14 Oct 2014 12:57:00 -0400 Subject: [PATCH] go/buildutil: use same logic as 'go' tool for pruning package search. The previous logic would descend into (e.g.) .git repositories and vendored packages with "_"-prefixed names. Fixes golang/go#8907 LGTM=gri R=gri CC=golang-codereviews, shurcool https://golang.org/cl/157800043 --- go/buildutil/allpackages.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/go/buildutil/allpackages.go b/go/buildutil/allpackages.go index 6ff28e3b..7ca3e585 100644 --- a/go/buildutil/allpackages.go +++ b/go/buildutil/allpackages.go @@ -77,9 +77,9 @@ func allPackages(ctxt *build.Context, sema chan bool, root string, found func(st var walkDir func(dir string) walkDir = func(dir string) { - // Prune search if we encounter any directory with these base names: - switch filepath.Base(dir) { - case "testdata", ".hg": + // Avoid .foo, _foo, and testdata directory trees. + base := filepath.Base(dir) + if base == "" || base[0] == '.' || base[0] == '_' || base == "testdata" { return }