Remove dead code.
diff --git a/cmd/flatten.go b/cmd/flatten.go
index f49d3b5..7f2534e 100644
--- a/cmd/flatten.go
+++ b/cmd/flatten.go
@@ -11,7 +11,7 @@
"github.com/Masterminds/glide/cfg"
"github.com/Masterminds/glide/dependency"
"github.com/Masterminds/glide/msg"
- //"github.com/Masterminds/glide/util"
+ "github.com/Masterminds/glide/util"
"github.com/Masterminds/semver"
)
@@ -59,17 +59,17 @@
f := &flattening{conf, vend, vend, deps, packages}
- pkgs, err := findAllProjects(f, strings.TrimSuffix(vend, "/vendor"))
- if err != nil {
- return conf, err
- }
- conf.Imports = pkgs
- return conf, nil
+ //pkgs, err := findAllProjects(f, strings.TrimSuffix(vend, "/vendor"))
+ //if err != nil {
+ //return conf, err
+ //}
+ //conf.Imports = pkgs
+ //return conf, nil
// 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)
+ err := recFlatten(f, force, home, cache, cacheGopath, skipGopath, scanned)
if err != nil {
return conf, err
}
@@ -328,6 +328,7 @@
UseCache: false,
UseCacheGopath: false,
SkipGopath: true,
+ alreadyDone: map[string]bool{},
}
resolved, err := resolver.ResolveAll([]*cfg.Dependency{&cfg.Dependency{Name: pkg}})
@@ -353,7 +354,7 @@
//scanned[d] = true
}
- msg.Info("Returning %v (len: %d)", cp, len(cp))
+ msg.Debug("Returning %v (len: %d)", cp, len(cp))
return cp, true
/*
@@ -544,12 +545,19 @@
type InstallMissingPackagesHandler struct {
Vendor, Home string
UseCache, UseCacheGopath, SkipGopath bool
+ alreadyDone map[string]bool
}
func (i *InstallMissingPackagesHandler) NotFound(pkg string) (bool, error) {
- d := &cfg.Dependency{Name: pkg}
- dest := filepath.Join(i.Vendor, pkg)
- msg.Info("Cloning %s into %s", pkg, dest)
+ proj := util.GetRootFromPackage(pkg)
+ if i.alreadyDone[proj] {
+ return true, nil
+ }
+ i.alreadyDone[proj] = true
+ d := &cfg.Dependency{Name: proj}
+ dest := filepath.Join(i.Vendor, proj)
+
+ msg.Info("Cloning %s into %s", proj, dest)
if err := VcsGet(d, dest, i.Home, i.UseCache, i.UseCacheGopath, i.SkipGopath); err != nil {
return false, err
}
diff --git a/cmd/get_imports.go b/cmd/get_imports.go
index 590ebae..894d469 100644
--- a/cmd/get_imports.go
+++ b/cmd/get_imports.go
@@ -827,3 +827,13 @@
}
return out
}
+
+// list2map takes a list of packages names and creates a map of normalized names.
+func list2map(in []string) map[string]bool {
+ out := make(map[string]bool, len(in))
+ for _, v := range in {
+ v, _ := NormalizeName(v)
+ out[v] = true
+ }
+ return out
+}
diff --git a/cmd/update_references.go b/cmd/update_references.go
deleted file mode 100644
index 176d972..0000000
--- a/cmd/update_references.go
+++ /dev/null
@@ -1,155 +0,0 @@
-package cmd
-
-import (
- "path/filepath"
-
- "github.com/Masterminds/cookoo"
- "github.com/Masterminds/glide/cfg"
- "github.com/Masterminds/glide/dependency"
-)
-
-// UpdateReferences updates the revision numbers on all of the imports.
-//
-// If a `packages` list is supplied, only the given base packages will
-// be updated.
-//
-// Params:
-// - conf (*cfg.Config): Configuration
-// - packages ([]string): A list of packages to update. Default is all packages.
-func UpdateReferences(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt) {
- conf := p.Get("conf", &cfg.Config{}).(*cfg.Config)
- plist := p.Get("packages", []string{}).([]string)
- vend, _ := VendorPath(c)
- pkgs := list2map(plist)
- restrict := len(pkgs) > 0
-
- cwd, err := VendorPath(c)
- if err != nil {
- return false, err
- }
-
- if len(conf.Imports) == 0 {
- return conf, nil
- }
-
- // Walk the dependency tree to discover all the packages to pin.
- packages := make([]string, len(conf.Imports))
- for i, v := range conf.Imports {
- packages[i] = v.Name
- }
- deps := make(map[string]*cfg.Dependency, len(conf.Imports))
- for _, imp := range conf.Imports {
- deps[imp.Name] = imp
- }
- f := &flattening{conf, vend, vend, deps, packages}
- err = discoverDependencyTree(f)
- if err != nil {
- return conf, err
- }
-
- exportFlattenedDeps(conf, deps)
-
- err = conf.DeDupe()
- if err != nil {
- return conf, err
- }
-
- for _, imp := range conf.Imports {
- if restrict && !pkgs[imp.Name] {
- Debug("===> Skipping %q", imp.Name)
- continue
- }
- commit, err := VcsLastCommit(imp, cwd)
- if err != nil {
- Warn("Could not get commit on %s: %s", imp.Name, err)
- }
- imp.Reference = commit
- }
-
- return conf, nil
-}
-
-func discoverDependencyTree(f *flattening) error {
- Debug("---> Inspecting %s for dependencies (%d packages).\n", f.curr, len(f.scan))
-
- // projects tracks which projects we have seen. Initially, it's everytning
- // in f.deps. As we go, we'll merge in all of the others that we find.
- projects := f.deps
-
- // Get all of the packages that are used.
- resolver, err := dependency.NewResolver(f.top)
- if err != nil {
- return err
- }
-
- dlist := make([]*cfg.Dependency, 0, len(f.deps))
- for _, d := range f.deps {
- dlist = append(dlist, d)
- }
- pkgs, err := resolver.ResolveAll(dlist)
- if err != nil {
- return err
- }
-
- // From the packages, we just want the repositories. So we get a normalized
- // list of dependencies.
- for _, d := range pkgs {
- d, err = filepath.Rel(f.top, d)
- if err != nil {
- Warn("Cannot resolve relative path: %s", err)
- }
- d, _ := NormalizeName(d)
-
- if _, ok := projects[d]; !ok {
- projects[d] = &cfg.Dependency{Name: d}
- Info("====> %s", d)
- }
- }
-
- // At this point, we know that we have an exhaustive list of packages, so
- // we can now just look for files that will tell us what version of each
- // package to use.
-
- /*
- scanned := map[string]bool{}
- for _, imp := range f.scan {
- Debug("----> Scanning %s", imp)
- base := path.Join(f.top, imp)
- mod := []string{}
- if m, ok := mergeGlide(base, imp, f.deps, f.top); ok {
- mod = m
- } else if m, ok = mergeGodep(base, imp, f.deps, f.top); ok {
- mod = m
- } else if m, ok = mergeGPM(base, imp, f.deps, f.top); ok {
- 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, scanned); ok {
- mod = m
- }
-
- if len(mod) > 0 {
- Debug("----> Looking for dependencies in %q (%d)", imp, len(mod))
- f2 := &flattening{
- conf: f.conf,
- top: f.top,
- curr: base,
- deps: f.deps,
- scan: mod}
- discoverDependencyTree(f2)
- }
- }
- */
-
- return nil
-}
-
-// list2map takes a list of packages names and creates a map of normalized names.
-func list2map(in []string) map[string]bool {
- out := make(map[string]bool, len(in))
- for _, v := range in {
- v, _ := NormalizeName(v)
- out[v] = true
- }
- return out
-}