Adding back support for --no-recursive flag
diff --git a/action/get.go b/action/get.go index 7b96782..cf5ed40 100644 --- a/action/get.go +++ b/action/get.go
@@ -15,7 +15,7 @@ // Get fetches one or more dependencies and installs. // // This includes resolving dependency resolution and re-generating the lock file. -func Get(names []string, installer *repo.Installer, insecure bool) { +func Get(names []string, installer *repo.Installer, insecure, skipRecursive bool) { base := gpath.Basepath() EnsureGopath() EnsureVendorDir() @@ -38,19 +38,22 @@ // Prior to resolving dependencies we need to start working with a clone // of the conf because we'll be making real changes to it. confcopy := conf.Clone() - installer.Config = confcopy - // Get all repos and update them. - // TODO: Can we streamline this in any way? The reason that we update all - // of the dependencies is that we need to re-negotiate versions. For example, - // if an existing dependency has the constraint >1.0 and this new package - // adds the constraint <2.0, then this may re-resolve the existing dependency - // to be betwee 1.0 and 2.0. But changing that dependency may then result - // in that dependency's dependencies changing... so we sorta do the whole - // thing to be safe. - err = installer.Update(confcopy) - if err != nil { - msg.Die("Could not update packages: %s", err) + if !skipRecursive { + installer.Config = confcopy + + // Get all repos and update them. + // TODO: Can we streamline this in any way? The reason that we update all + // of the dependencies is that we need to re-negotiate versions. For example, + // if an existing dependency has the constraint >1.0 and this new package + // adds the constraint <2.0, then this may re-resolve the existing dependency + // to be betwee 1.0 and 2.0. But changing that dependency may then result + // in that dependency's dependencies changing... so we sorta do the whole + // thing to be safe. + err = installer.Update(confcopy) + if err != nil { + msg.Die("Could not update packages: %s", err) + } } // Set Reference @@ -67,9 +70,12 @@ if err := conf.WriteFile(glidefile); err != nil { msg.Die("Failed to write glide YAML file: %s", err) } - - // Write lock - writeLock(conf, confcopy, base) + if !skipRecursive { + // Write lock + writeLock(conf, confcopy, base) + } else { + msg.Warn("Skipping lockfile generation because full dependency tree is not being calculated") + } } func writeLock(conf, confcopy *cfg.Config, base string) {
diff --git a/action/update.go b/action/update.go index a671e8d..47f5e47 100644 --- a/action/update.go +++ b/action/update.go
@@ -11,7 +11,7 @@ ) // Update updates repos and the lock file from the main glide yaml. -func Update(installer *repo.Installer) { +func Update(installer *repo.Installer, skipRecursive bool) { base := "." EnsureGopath() EnsureVendorDir() @@ -35,40 +35,42 @@ msg.Die("Failed to set initial config references: %s", err) } - // Prior to resolving dependencies we need to start working with a clone - // of the conf because we'll be making real changes to it. confcopy := conf.Clone() - installer.Config = confcopy - // Get all repos and update them. - err := installer.Update(confcopy) - if err != nil { - msg.Die("Could not update packages: %s", err) + if !skipRecursive { + // Prior to resolving dependencies we need to start working with a clone + // of the conf because we'll be making real changes to it. + installer.Config = confcopy + + // Get all repos and update them. + err := installer.Update(confcopy) + if err != nil { + msg.Die("Could not update packages: %s", err) + } + + // TODO: There is no support here for importing Godeps, GPM, and GB files. + // I think that all we really need to do now is hunt for these files, and then + // roll their version numbers into the config file. + + // Set references. There may be no remaining references to set since the + // installer set them as it went to make sure it parsed the right imports + // from the right version of the package. + msg.Info("Setting references for remaining imports") + if err := repo.SetReference(confcopy); err != nil { + msg.Error("Failed to set references: %s (Skip to cleanup)", err) + } + + // Flatten + // I don't think we need flatten anymore. The installer.Update logic should + // find and install all of the necessary dependencies. And then the version + // setting logic should correctly set versions. + // + // The edge case, which exist today (but innoculously) is where an older + // version requires dependencies that a newer repo checkout does not + // have. In that case, it seems that we may get to the point where we'd + // have to run Update twice. + msg.Warn("Flatten not implemented.") } - - // TODO: There is no support here for importing Godeps, GPM, and GB files. - // I think that all we really need to do now is hunt for these files, and then - // roll their version numbers into the config file. - - // Set references. There may be no remaining references to set since the - // installer set them as it went to make sure it parsed the right imports - // from the right version of the package. - msg.Info("Setting references for remaining imports") - if err := repo.SetReference(confcopy); err != nil { - msg.Error("Failed to set references: %s (Skip to cleanup)", err) - } - - // Flatten - // I don't think we need flatten anymore. The installer.Update logic should - // find and install all of the necessary dependencies. And then the version - // setting logic should correctly set versions. - // - // The edge case, which exist today (but innoculously) is where an older - // version requires dependencies that a newer repo checkout does not - // have. In that case, it seems that we may get to the point where we'd - // have to run Update twice. - msg.Warn("Flatten not implemented.") - // Vendored cleanup // VendoredCleanup. This should ONLY be run if UpdateVendored was specified. if installer.UpdateVendored { @@ -84,50 +86,20 @@ // from the project. A removed dependency should warn and an added dependency // should be added to the glide.yaml file. See issue #193. - // Write lock - hash, err := conf.Hash() - if err != nil { - msg.Die("Failed to generate config hash. Unable to generate lock file.") + if !skipRecursive { + // Write lock + hash, err := conf.Hash() + if err != nil { + msg.Die("Failed to generate config hash. Unable to generate lock file.") + } + lock := cfg.NewLockfile(confcopy.Imports, hash) + if err := lock.WriteFile(filepath.Join(base, gpath.LockFile)); err != nil { + msg.Error("Could not write lock file to %s: %s", base, err) + return + } + + msg.Info("Project relies on %d dependencies.", len(confcopy.Imports)) + } else { + msg.Warn("Skipping lockfile generation because full dependency tree is not being calculated") } - lock := cfg.NewLockfile(confcopy.Imports, hash) - if err := lock.WriteFile(filepath.Join(base, gpath.LockFile)); err != nil { - msg.Error("Could not write lock file to %s: %s", base, err) - return - } - - msg.Info("Project relies on %d dependencies.", len(confcopy.Imports)) - - /* - Does(cmd.VendoredSetup, "cfg"). - Using("conf").From("cxt:cfg"). - Using("update").From("cxt:updateVendoredDeps"). - - Does(cmd.UpdateImports, "dependencies"). - Using("conf").From("cxt:cfg"). - Using("force").From("cxt:forceUpdate"). - Using("packages").From("cxt:packages"). - Using("home").From("cxt:home"). - Using("cache").From("cxt:useCache"). - Using("cacheGopath").From("cxt:cacheGopath"). - 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"). - Using("force").From("cxt:forceUpdate"). - Using("skip").From("cxt:skipFlatten"). - Using("home").From("cxt:home"). - Using("cache").From("cxt:useCache"). - Using("cacheGopath").From("cxt:cacheGopath"). - Using("useGopath").From("cxt:useGopath"). - Does(cmd.VendoredCleanUp, "_"). - Using("conf").From("cxt:flattened"). - Using("update").From("cxt:updateVendoredDeps"). - Does(cmd.WriteYaml, "out"). - Using("conf").From("cxt:cfg"). - Using("filename").From("cxt:toPath"). - Using("toStdout").From("cxt:toStdout"). - Does(cmd.WriteLock, "lock"). - Using("lockfile").From("cxt:Lockfile"). - Using("skip").From("cxt:skipFlatten") - */ }
diff --git a/glide.go b/glide.go index 97e0dfb..e7900a8 100644 --- a/glide.go +++ b/glide.go
@@ -202,7 +202,7 @@ } packages := []string(c.Args()) insecure := c.Bool("insecure") - action.Get(packages, inst, insecure) + action.Get(packages, inst, insecure, c.Bool("no-recursive")) }, }, { @@ -344,10 +344,6 @@ Usage: "Delete vendor packages not specified in config.", }, cli.BoolFlag{ - Name: "no-recursive, quick", - Usage: "Disable updating dependencies' dependencies. Only update things in glide.yaml. (DEPRECATED: This no longer has any effect.)", - }, - cli.BoolFlag{ Name: "force", Usage: "If there was a change in the repo or VCS switch to new one. Warning: changes will be lost.", }, @@ -460,7 +456,7 @@ Home: gpath.Home(), } - action.Update(installer) + action.Update(installer, c.Bool("no-recursive")) }, }, {