Updating install to use the cache by default
diff --git a/action/install.go b/action/install.go index 3e28788..b3f5052 100644 --- a/action/install.go +++ b/action/install.go
@@ -1,18 +1,18 @@ package action import ( + "fmt" "path/filepath" "github.com/Masterminds/glide/cache" "github.com/Masterminds/glide/cfg" - "github.com/Masterminds/glide/dependency" "github.com/Masterminds/glide/msg" gpath "github.com/Masterminds/glide/path" "github.com/Masterminds/glide/repo" ) // Install installs a vendor directory based on an existing Glide configuration. -func Install(installer *repo.Installer, strip, stripVendor bool) { +func Install(installer *repo.Installer, stripVendor bool) { if installer.UseCache { cache.SystemLock() } @@ -39,6 +39,9 @@ if err != nil { msg.Die("Could not load lockfile.") } else if hash != lock.Hash { + fmt.Println(hash, lock.Hash) + foo, _ := conf.Marshal() + fmt.Println(string(foo)) msg.Warn("Lock file may be out of date. Hash check of YAML failed. You may need to run 'update'") } @@ -55,26 +58,9 @@ msg.Err("Failed to set references: %s (Skip to cleanup)", err) } - // Delete unused packages - if installer.DeleteUnused { - // newConf is calculated based on the lock file so it should be - // accurate to the project list. - dependency.DeleteUnused(newConf) - } - - // VendoredCleanup. This should ONLY be run if UpdateVendored was specified. - // When stripping VCS happens this will happen as well. No need for double - // effort. - if installer.UpdateVendored && !strip { - repo.VendoredCleanup(newConf) - } - - if strip { - msg.Info("Removing version control data from vendor directory...") - err := gpath.StripVcs() - if err != nil { - msg.Err("Unable to strip version control data: %s", err) - } + err = installer.Export(newConf) + if err != nil { + msg.Die("Unable to export dependencies to vendor directory: %s", err) } if stripVendor {
diff --git a/glide.go b/glide.go index f86b491..2e7cb1d 100644 --- a/glide.go +++ b/glide.go
@@ -441,36 +441,43 @@ from the lock file.`, Flags: []cli.Flag{ cli.BoolFlag{ - Name: "delete", - Usage: "Delete vendor packages not specified in config.", + Name: "delete", + Usage: "Delete vendor packages not specified in config.", + Hidden: true, }, cli.BoolFlag{ Name: "force", Usage: "If there was a change in the repo or VCS switch to new one. Warning: changes will be lost.", }, cli.BoolFlag{ - Name: "update-vendored, u", - Usage: "Update vendored packages (without local VCS repo). Warning: this may destroy local modifications to vendor/.", + Name: "update-vendored, u", + Usage: "Update vendored packages (without local VCS repo). Warning: this may destroy local modifications to vendor/.", + Hidden: true, }, cli.StringFlag{ - Name: "file, f", - Usage: "Save all of the discovered dependencies to a Glide YAML file. (DEPRECATED: This has no impact.)", + Name: "file, f", + Usage: "Save all of the discovered dependencies to a Glide YAML file. (DEPRECATED: This has no impact.)", + Hidden: true, }, cli.BoolFlag{ - Name: "cache", - Usage: "When downloading dependencies attempt to cache them.", + Name: "cache", + Usage: "When downloading dependencies attempt to cache them.", + Hidden: true, }, cli.BoolFlag{ - Name: "cache-gopath", - Usage: "When downloading dependencies attempt to put them in the GOPATH, too.", + Name: "cache-gopath", + Usage: "When downloading dependencies attempt to put them in the GOPATH, too.", + Hidden: true, }, cli.BoolFlag{ - Name: "use-gopath", - Usage: "Copy dependencies from the GOPATH if they exist there.", + Name: "use-gopath", + Usage: "Copy dependencies from the GOPATH if they exist there.", + Hidden: true, }, cli.BoolFlag{ - Name: "strip-vcs, s", - Usage: "Removes version control metadata (e.g, .git directory) from the vendor folder.", + Name: "strip-vcs, s", + Usage: "Removes version control metadata (e.g, .git directory) from the vendor folder.", + Hidden: true, }, cli.BoolFlag{ Name: "strip-vendor, v", @@ -482,21 +489,34 @@ }, }, Action: func(c *cli.Context) error { - if c.Bool("strip-vendor") && !c.Bool("strip-vcs") { - msg.Die("--strip-vendor cannot be used without --strip-vcs") + if c.Bool("delete") { + msg.Warn("The --delete flag is deprecated. This now works by default.") + } + if c.Bool("update-vendored") { + msg.Warn("The --update-vendored flag is deprecated. This now works by default.") + } + if c.String("file") != "" { + msg.Warn("The --flag flag is deprecated.") + } + if c.Bool("cache") { + msg.Warn("The --cache flag is deprecated. This now works by default.") + } + if c.Bool("cache-gopath") { + msg.Warn("The --cache-gopath flag is deprecated.") + } + if c.Bool("use-gopath") { + msg.Warn("The --use-gopath flag is deprecated. Please see overrides.") + } + if c.Bool("strip-vcs") { + msg.Warn("The --strip-vcs flag is deprecated. This now works by default.") } installer := repo.NewInstaller() installer.Force = c.Bool("force") - installer.UseCache = c.Bool("cache") - installer.UseGopath = c.Bool("use-gopath") - installer.UseCacheGopath = c.Bool("cache-gopath") - installer.UpdateVendored = c.Bool("update-vendored") installer.Home = c.GlobalString("home") - installer.DeleteUnused = c.Bool("delete") installer.ResolveTest = !c.Bool("skip-test") - action.Install(installer, c.Bool("strip-vcs"), c.Bool("strip-vendor")) + action.Install(installer, c.Bool("strip-vendor")) return nil }, }, @@ -609,10 +629,6 @@ msg.Warn("The --strip-vcs flag is deprecated. This now works by default.") } - if c.Bool("strip-vendor") && !c.Bool("strip-vcs") { - msg.Die("--strip-vendor cannot be used without --strip-vcs") - } - if c.Bool("resolve-current") { util.ResolveCurrent = true msg.Warn("Only resolving dependencies for the current OS/Arch")
diff --git a/glide.lock b/glide.lock index 5f4169c..04390b5 100644 --- a/glide.lock +++ b/glide.lock
@@ -1,5 +1,5 @@ hash: 84b989218da3e6a1480e6fa95864e838b1e676a970a14d65fffd33cf052a84fd -updated: 2016-08-11T13:15:29.781819924-04:00 +updated: 2016-08-11T13:38:46.721068785-04:00 imports: - name: github.com/codegangsta/cli version: 1efa31f08b9333f1bd4882d61f9d668a70cd902e
diff --git a/repo/installer.go b/repo/installer.go index 206fb6e..99a6452 100644 --- a/repo/installer.go +++ b/repo/installer.go
@@ -82,11 +82,6 @@ // Install installs the dependencies from a Lockfile. func (i *Installer) Install(lock *cfg.Lockfile, conf *cfg.Config) (*cfg.Config, error) { - cwd, err := gpath.Vendor() - if err != nil { - return conf, err - } - // Create a config setup based on the Lockfile data to process with // existing commands. newConf := &cfg.Config{} @@ -111,8 +106,8 @@ msg.Info("Downloading dependencies. Please wait...") - LazyConcurrentUpdate(newConf.Imports, cwd, i, newConf) - LazyConcurrentUpdate(newConf.DevImports, cwd, i, newConf) + LazyConcurrentUpdate(newConf.Imports, i, newConf) + LazyConcurrentUpdate(newConf.DevImports, i, newConf) return newConf, nil } @@ -122,16 +117,14 @@ // vendor directory based on changed config. func (i *Installer) Checkout(conf *cfg.Config) error { - dest := i.VendorPath() - msg.Info("Downloading dependencies. Please wait...") - if err := ConcurrentUpdate(conf.Imports, dest, i, conf); err != nil { + if err := ConcurrentUpdate(conf.Imports, i, conf); err != nil { return err } if i.ResolveTest { - return ConcurrentUpdate(conf.DevImports, dest, i, conf) + return ConcurrentUpdate(conf.DevImports, i, conf) } return nil @@ -251,13 +244,13 @@ msg.Info("Downloading dependencies. Please wait...") - err = ConcurrentUpdate(conf.Imports, vpath, i, conf) + err = ConcurrentUpdate(conf.Imports, i, conf) if err != nil { return err } if i.ResolveTest { - err = ConcurrentUpdate(conf.DevImports, vpath, i, conf) + err = ConcurrentUpdate(conf.DevImports, i, conf) if err != nil { return err } @@ -390,7 +383,7 @@ // LazyConcurrentUpdate updates only deps that are not already checkout out at the right version. // // This is only safe when updating from a lock file. -func LazyConcurrentUpdate(deps []*cfg.Dependency, cwd string, i *Installer, c *cfg.Config) error { +func LazyConcurrentUpdate(deps []*cfg.Dependency, i *Installer, c *cfg.Config) error { newDeps := []*cfg.Dependency{} for _, dep := range deps { @@ -418,14 +411,14 @@ newDeps = append(newDeps, dep) } if len(newDeps) > 0 { - return ConcurrentUpdate(newDeps, cwd, i, c) + return ConcurrentUpdate(newDeps, i, c) } return nil } // ConcurrentUpdate takes a list of dependencies and updates in parallel. -func ConcurrentUpdate(deps []*cfg.Dependency, cwd string, i *Installer, c *cfg.Config) error { +func ConcurrentUpdate(deps []*cfg.Dependency, i *Installer, c *cfg.Config) error { done := make(chan struct{}, concurrentWorkers) in := make(chan *cfg.Dependency, concurrentWorkers) var wg sync.WaitGroup