Issue #155: Making copying from GOPATH opt-in There can be issues copying from the GOPATH. Because of this copying from the GOPATH should be opt-in.
diff --git a/cmd/flatten.go b/cmd/flatten.go index 1bf9adc..1df75ec 100644 --- a/cmd/flatten.go +++ b/cmd/flatten.go
@@ -31,7 +31,7 @@ home := p.Get("home", "").(string) cache := p.Get("cache", false).(bool) cacheGopath := p.Get("cacheGopath", false).(bool) - skipGopath := p.Get("skipGopath", false).(bool) + useGopath := p.Get("useGopath", false).(bool) if skip { return conf, nil @@ -59,7 +59,7 @@ // 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, useGopath, scanned) if err != nil { return conf, err } @@ -109,7 +109,7 @@ var updateCache = map[string]bool{} // refFlatten recursively flattens the vendor tree. -func recFlatten(f *flattening, force bool, home string, cache, cacheGopath, skipGopath bool, scanned map[string]bool) error { +func recFlatten(f *flattening, force bool, home string, cache, cacheGopath, useGopath 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) @@ -129,14 +129,14 @@ if len(mod) > 0 { Debug("----> Updating all dependencies for %q (%d)", imp, len(mod)) - flattenGlideUp(f, base, home, force, cache, cacheGopath, skipGopath) + flattenGlideUp(f, base, home, force, cache, cacheGopath, useGopath) f2 := &flattening{ conf: f.conf, top: f.top, curr: base, deps: f.deps, scan: mod} - recFlatten(f2, force, home, cache, cacheGopath, skipGopath, scanned) + recFlatten(f2, force, home, cache, cacheGopath, useGopath, scanned) } } @@ -148,7 +148,7 @@ // While this is expensive, it is also necessary to make sure we have the // correct version of all dependencies. We might be able to simplify by // marking packages dirty when they are added. -func flattenGlideUp(f *flattening, base, home string, force, cache, cacheGopath, skipGopath bool) error { +func flattenGlideUp(f *flattening, base, home string, force, cache, cacheGopath, useGopath bool) error { //vdir := path.Join(base, "vendor") for _, imp := range f.deps { // If the top package name in the glide.yaml file is present in the deps @@ -163,7 +163,7 @@ continue } Debug("Updating project %s (%s)\n", imp.Name, wd) - if err := VcsUpdate(imp, f.top, home, force, cache, cacheGopath, skipGopath); err != nil { + if err := VcsUpdate(imp, f.top, home, force, cache, cacheGopath, useGopath); err != nil { // We can still go on just fine even if this fails. Warn("Skipped update %s: %s\n", imp.Name, err) continue @@ -171,7 +171,7 @@ updateCache[imp.Name] = true } else { Debug("Importing %s to project %s\n", imp.Name, wd) - if err := VcsGet(imp, wd, home, cache, cacheGopath, skipGopath); err != nil { + if err := VcsGet(imp, wd, home, cache, cacheGopath, useGopath); err != nil { Warn("Skipped getting %s: %v\n", imp.Name, err) continue }
diff --git a/cmd/get_imports.go b/cmd/get_imports.go index ab103eb..4815175 100644 --- a/cmd/get_imports.go +++ b/cmd/get_imports.go
@@ -51,7 +51,7 @@ home := p.Get("home", "").(string) cache := p.Get("cache", false).(bool) cacheGopath := p.Get("cacheGopath", false).(bool) - skipGopath := p.Get("skipGopath", false).(bool) + useGopath := p.Get("useGopath", false).(bool) Info("Preparing to install %d package.", len(names)) @@ -98,7 +98,7 @@ if len(subpkg) > 0 && subpkg != "/" { dep.Subpackages = []string{subpkg} } - if err := VcsGet(dep, dest, home, cache, cacheGopath, skipGopath); err != nil { + if err := VcsGet(dep, dest, home, cache, cacheGopath, useGopath); err != nil { return dep, err } @@ -124,7 +124,7 @@ home := p.Get("home", "").(string) cache := p.Get("cache", false).(bool) cacheGopath := p.Get("cacheGopath", false).(bool) - skipGopath := p.Get("skipGopath", false).(bool) + useGopath := p.Get("useGopath", false).(bool) pkgs := list2map(plist) restrict := len(pkgs) > 0 @@ -150,7 +150,7 @@ // flattening from causing unnecessary updates. updateCache[dep.Name] = true - if err := VcsUpdate(dep, cwd, home, force, cache, cacheGopath, skipGopath); err != nil { + if err := VcsUpdate(dep, cwd, home, force, cache, cacheGopath, useGopath); err != nil { Warn("Update failed for %s: %s\n", dep.Name, err) } } @@ -259,9 +259,9 @@ // VcsGet figures out how to fetch a dependency, and then gets it. // // VcsGet installs into the dest. -func VcsGet(dep *cfg.Dependency, dest, home string, cache, cacheGopath, skipGopath bool) error { +func VcsGet(dep *cfg.Dependency, dest, home string, cache, cacheGopath, useGopath bool) error { // When not skipping the $GOPATH look in it for a copy of the package - if !skipGopath { + if useGopath { // Check if the $GOPATH has a viable version to use and if so copy to vendor gps := Gopaths() for _, p := range gps { @@ -464,7 +464,7 @@ } // VcsUpdate updates to a particular checkout based on the VCS setting. -func VcsUpdate(dep *cfg.Dependency, vend, home string, force, cache, cacheGopath, skipGopath bool) error { +func VcsUpdate(dep *cfg.Dependency, vend, home string, force, cache, cacheGopath, useGopath bool) error { Info("Fetching updates for %s.\n", dep.Name) if filterArchOs(dep) { @@ -475,7 +475,7 @@ dest := path.Join(vend, dep.Name) // If destination doesn't exist we need to perform an initial checkout. if _, err := os.Stat(dest); os.IsNotExist(err) { - if err = VcsGet(dep, dest, home, cache, cacheGopath, skipGopath); err != nil { + if err = VcsGet(dep, dest, home, cache, cacheGopath, useGopath); err != nil { Warn("Unable to checkout %s\n", dep.Name) return err } @@ -512,7 +512,7 @@ if rerr != nil { return rerr } - if err = VcsGet(dep, dest, home, cache, cacheGopath, skipGopath); err != nil { + if err = VcsGet(dep, dest, home, cache, cacheGopath, useGopath); err != nil { Warn("Unable to checkout %s\n", dep.Name) return err }
diff --git a/cmd/install.go b/cmd/install.go index b388947..3f58edd 100644 --- a/cmd/install.go +++ b/cmd/install.go
@@ -57,7 +57,7 @@ home := p.Get("home", "").(string) cache := p.Get("cache", false).(bool) cacheGopath := p.Get("cacheGopath", false).(bool) - skipGopath := p.Get("skipGopath", false).(bool) + useGopath := p.Get("useGopath", false).(bool) cwd, err := VendorPath(c) if err != nil { @@ -103,7 +103,7 @@ } // for _, dep := range newConf.Imports { - // if err := VcsUpdate(dep, cwd, home, force, cache, cacheGopath, skipGopath); err != nil { + // if err := VcsUpdate(dep, cwd, home, force, cache, cacheGopath, useGopath); err != nil { // Warn("Update failed for %s: %s\n", dep.Name, err) // } // } @@ -117,7 +117,7 @@ for { select { case dep := <-ch: - if err := VcsUpdate(dep, cwd, home, force, cache, cacheGopath, skipGopath); err != nil { + if err := VcsUpdate(dep, cwd, home, force, cache, cacheGopath, useGopath); err != nil { Warn("Update failed for %s: %s\n", dep.Name, err) } wg.Done()
diff --git a/glide.go b/glide.go index fee0aea..04bd3e7 100644 --- a/glide.go +++ b/glide.go
@@ -185,8 +185,8 @@ Usage: "When downloading dependencies attempt to put them in the GOPATH, too.", }, cli.BoolFlag{ - Name: "skip-gopath", - Usage: "Skip attempting to copy a dependency from the GOPATH.", + Name: "use-gopath", + Usage: "Copy dependencies from the GOPATH if they exist there.", }, }, Action: func(c *cli.Context) { @@ -199,7 +199,7 @@ cxt.Put("insecure", c.Bool("insecure")) cxt.Put("useCache", c.Bool("cache")) cxt.Put("cacheGopath", c.Bool("cache-gopath")) - cxt.Put("skipGopath", c.Bool("skip-gopath")) + cxt.Put("useGopath", c.Bool("use-gopath")) // FIXME: Are these used anywhere? if c.Bool("import") { cxt.Put("importGodeps", true) @@ -352,8 +352,8 @@ Usage: "When downloading dependencies attempt to put them in the GOPATH, too.", }, cli.BoolFlag{ - Name: "skip-gopath", - Usage: "Skip attempting to copy a dependency from the GOPATH.", + Name: "use-gopath", + Usage: "Copy dependencies from the GOPATH if they exist there.", }, }, Action: func(c *cli.Context) { @@ -365,7 +365,7 @@ cxt.Put("toStdout", false) cxt.Put("useCache", c.Bool("cache")) cxt.Put("cacheGopath", c.Bool("cache-gopath")) - cxt.Put("skipGopath", c.Bool("skip-gopath")) + cxt.Put("useGopath", c.Bool("use-gopath")) if c.Bool("import") { cxt.Put("importGodeps", true) cxt.Put("importGPM", true) @@ -435,8 +435,8 @@ Usage: "When downloading dependencies attempt to put them in the GOPATH, too.", }, cli.BoolFlag{ - Name: "skip-gopath", - Usage: "Skip attempting to copy a dependency from the GOPATH.", + Name: "use-gopath", + Usage: "Copy dependencies from the GOPATH if they exist there.", }, }, Action: func(c *cli.Context) { @@ -448,7 +448,7 @@ cxt.Put("toStdout", false) cxt.Put("useCache", c.Bool("cache")) cxt.Put("cacheGopath", c.Bool("cache-gopath")) - cxt.Put("skipGopath", c.Bool("skip-gopath")) + cxt.Put("useGopath", c.Bool("use-gopath")) if c.Bool("import") { cxt.Put("importGodeps", true) cxt.Put("importGPM", true) @@ -537,14 +537,14 @@ Using("home").From("cxt:home"). Using("cache").From("cxt:useCache"). Using("cacheGopath").From("cxt:cacheGopath"). - Using("skipGopath").From("cxt:skipGopath"). + Using("useGopath").From("cxt:useGopath"). Does(cmd.Flatten, "flatten").Using("conf").From("cxt:cfg"). Using("packages").From("cxt:packages"). Using("force").From("cxt:forceUpdate"). Using("home").From("cxt:home"). Using("cache").From("cxt:useCache"). Using("cacheGopath").From("cxt:cacheGopath"). - Using("skipGopath").From("cxt:skipGopath"). + Using("useGopath").From("cxt:useGopath"). Does(cmd.WriteYaml, "out"). Using("conf").From("cxt:cfg"). Using("filename").WithDefault("glide.yaml").From("cxt:yaml"). @@ -592,7 +592,7 @@ Using("home").From("cxt:home"). Using("cache").From("cxt:useCache"). Using("cacheGopath").From("cxt:cacheGopath"). - Using("skipGopath").From("cxt:skipGopath"). + Using("useGopath").From("cxt:useGopath"). Does(cmd.SetReference, "version").Using("conf").From("cxt:cfg"). Does(cmd.Flatten, "flattened").Using("conf").From("cxt:cfg"). Using("packages").From("cxt:packages"). @@ -601,7 +601,7 @@ Using("home").From("cxt:home"). Using("cache").From("cxt:useCache"). Using("cacheGopath").From("cxt:cacheGopath"). - Using("skipGopath").From("cxt:skipGopath"). + Using("useGopath").From("cxt:useGopath"). Does(cmd.VendoredCleanUp, "_"). Using("conf").From("cxt:flattened"). Using("update").From("cxt:updateVendoredDeps"). @@ -630,7 +630,7 @@ Using("home").From("cxt:home"). Using("cache").From("cxt:useCache"). Using("cacheGopath").From("cxt:cacheGopath"). - Using("skipGopath").From("cxt:skipGopath"). + Using("useGopath").From("cxt:useGopath"). //Does(cmd.VendoredCleanUp, "_"). //Using("conf").From("cxt:flattened"). //Using("update").From("cxt:updateVendoredDeps").