Re-enable source code scanning on up/get.
diff --git a/cmd/flatten.go b/cmd/flatten.go
index 652b522..d24fd54 100644
--- a/cmd/flatten.go
+++ b/cmd/flatten.go
@@ -7,6 +7,7 @@
"strings"
"github.com/Masterminds/cookoo"
+ "github.com/Masterminds/glide/util"
"github.com/Masterminds/glide/yaml"
"github.com/Masterminds/semver"
)
@@ -55,7 +56,10 @@
f := &flattening{conf, vend, vend, deps, packages}
- err := recFlatten(f, force, home, cache, cacheGopath, skipGopath)
+ // The assumption here is that once something has been scanned once in a
+ // run, there is no need to scan it again.
+ scanned := map[string]bool{}
+ err := recFlatten(f, force, home, cache, cacheGopath, skipGopath, scanned)
if err != nil {
return conf, err
}
@@ -99,7 +103,7 @@
var updateCache = map[string]bool{}
// refFlatten recursively flattens the vendor tree.
-func recFlatten(f *flattening, force bool, home string, cache, cacheGopath, skipGopath bool) error {
+func recFlatten(f *flattening, force bool, home string, cache, cacheGopath, skipGopath bool, scanned map[string]bool) error {
Debug("---> Inspecting %s for changes (%d packages).\n", f.curr, len(f.scan))
for _, imp := range f.scan {
Debug("----> Scanning %s", imp)
@@ -113,9 +117,11 @@
mod = m
} else if m, ok = mergeGb(base, imp, f.deps, f.top); ok {
mod = m
- } else if m, ok = mergeGuess(base, imp, f.deps, f.top); ok {
+ } else if m, ok = mergeGuess(base, imp, f.deps, f.top, scanned); ok {
mod = m
}
+ //mod, _ = mergeGuess(base, imp, f.deps, f.top, scanned)
+ //Info("Scanned: %v", scanned)
if len(mod) > 0 {
Debug("----> Updating all dependencies for %q (%d)", imp, len(mod))
@@ -126,7 +132,7 @@
curr: base,
deps: f.deps,
scan: mod}
- recFlatten(f2, force, home, cache, cacheGopath, skipGopath)
+ recFlatten(f2, force, home, cache, cacheGopath, skipGopath, scanned)
}
}
@@ -254,59 +260,67 @@
// This always returns true because it always handles the job of searching
// for dependencies. So generally it should be the last merge strategy
// that you try.
-func mergeGuess(dir, pkg string, deps map[string]*yaml.Dependency, vend string) ([]string, bool) {
- /*
- Info("Scanning %s for dependencies.", pkg)
- buildContext, err := GetBuildContext()
- if err != nil {
- Warn("Could not scan package %q: %s", pkg, err)
- return []string{}, false
- }
+func mergeGuess(dir, pkg string, deps map[string]*yaml.Dependency, vend string, scanned map[string]bool) ([]string, bool) {
+ Info("Scanning %s for dependencies.", pkg)
+ buildContext, err := GetBuildContext()
+ if err != nil {
+ Warn("Could not scan package %q: %s", pkg, err)
+ return []string{}, false
+ }
- res := []string{}
+ res := []string{}
- if _, err := os.Stat(dir); err != nil {
- Warn("Directory is missing: %s", dir)
- return res, true
- }
-
- d := walkDeps(buildContext, dir, pkg)
- for _, name := range d {
- name, _ := NormalizeName(name)
- repo := getRepoRootFromPackage(name)
- if _, ok := deps[name]; ok {
- Debug("====> Seen %s already. Skipping", name)
- continue
- }
-
- found := findPkg(buildContext, name, dir)
- switch found.PType {
- case ptypeUnknown:
- Debug("✨☆ Undownloaded dependency: %s", name)
- nd := &Dependency{
- Name: name,
- Repository: "https://" + repo,
- }
- deps[name] = nd
- res = append(res, name)
- case ptypeGoroot, ptypeCgo:
- break
- default:
- // We're looking for dependencies that might exist in $GOPATH
- // but not be on vendor. We add any that are on $GOPATH.
- if _, ok := deps[name]; !ok {
- Debug("✨☆ GOPATH dependency: %s", name)
- nd := &Dependency{Name: name}
- deps[name] = nd
- res = append(res, name)
- }
- }
- }
-
+ if _, err := os.Stat(dir); err != nil {
+ Warn("Directory is missing: %s", dir)
return res, true
- */
- Info("Package %s manages its own dependencies", pkg)
- return []string{}, true
+ }
+
+ d := walkDeps(buildContext, dir, pkg)
+ for _, oname := range d {
+ if _, ok := scanned[oname]; ok {
+ //Info("===> Scanned %s already. Skipping", name)
+ continue
+ }
+ Info("=> Scanning %s", oname)
+ name, _ := NormalizeName(oname)
+ //if _, ok := deps[name]; ok {
+ //scanned[oname] = true
+ //Debug("====> Seen %s already. Skipping", name)
+ //continue
+ //}
+
+ repo := util.GetRootFromPackage(name)
+ found := findPkg(buildContext, name, dir)
+ switch found.PType {
+ case ptypeUnknown:
+ Info("==> Unknown %s (%s)", name, oname)
+ Debug("✨☆ Undownloaded dependency: %s", name)
+ nd := &yaml.Dependency{
+ Name: name,
+ Repository: "https://" + repo,
+ }
+ deps[name] = nd
+ res = append(res, name)
+ case ptypeGoroot, ptypeCgo:
+ scanned[oname] = true
+ // Why do we break rather than continue?
+ break
+ default:
+ // We're looking for dependencies that might exist in $GOPATH
+ // but not be on vendor. We add any that are on $GOPATH.
+ if _, ok := deps[name]; !ok {
+ Debug("✨☆ GOPATH dependency: %s", name)
+ nd := &yaml.Dependency{Name: name}
+ deps[name] = nd
+ res = append(res, name)
+ }
+ scanned[oname] = true
+ }
+ }
+
+ return res, true
+ //Info("Package %s manages its own dependencies", pkg)
+ //return []string{}, true
}
// mergeDeps merges any dependency array into deps.
diff --git a/cmd/tree.go b/cmd/tree.go
index b521641..8983c4a 100644
--- a/cmd/tree.go
+++ b/cmd/tree.go
@@ -223,7 +223,11 @@
pkg, err := b.ImportDir(path, 0)
if err != nil {
- return err
+ if !strings.HasPrefix(err.Error(), "no buildable Go source") {
+ Warn("Error: %s (%s)", err, path)
+ // Not sure if we should return here.
+ //return err
+ }
}
if pkg.Goroot {
diff --git a/cmd/update_references.go b/cmd/update_references.go
index c81a95c..3e602fa 100644
--- a/cmd/update_references.go
+++ b/cmd/update_references.go
@@ -70,6 +70,7 @@
func discoverDependencyTree(f *flattening) error {
Debug("---> Inspecting %s for dependencies (%d packages).\n", f.curr, len(f.scan))
+ scanned := map[string]bool{}
for _, imp := range f.scan {
Debug("----> Scanning %s", imp)
base := path.Join(f.top, imp)
@@ -82,7 +83,7 @@
mod = m
} else if m, ok = mergeGb(base, imp, f.deps, f.top); ok {
mod = m
- } else if m, ok = mergeGuess(base, imp, f.deps, f.top); ok {
+ } else if m, ok = mergeGuess(base, imp, f.deps, f.top, scanned); ok {
mod = m
}