Updating the update command to resolve in the cache directory
diff --git a/action/install.go b/action/install.go
index b1566a2..3e28788 100644
--- a/action/install.go
+++ b/action/install.go
@@ -26,7 +26,7 @@
// Lockfile exists
if !gpath.HasLock(base) {
msg.Info("Lock file (glide.lock) does not exist. Performing update.")
- Update(installer, false, strip, stripVendor)
+ Update(installer, false, stripVendor)
return
}
// Load lockfile
diff --git a/action/update.go b/action/update.go
index bdd3c62..219c98e 100644
--- a/action/update.go
+++ b/action/update.go
@@ -6,15 +6,13 @@
"github.com/Masterminds/glide/cache"
"github.com/Masterminds/glide/cfg"
- "github.com/Masterminds/glide/dependency"
- "github.com/Masterminds/glide/godep"
"github.com/Masterminds/glide/msg"
gpath "github.com/Masterminds/glide/path"
"github.com/Masterminds/glide/repo"
)
// Update updates repos and the lock file from the main glide yaml.
-func Update(installer *repo.Installer, skipRecursive, strip, stripVendor bool) {
+func Update(installer *repo.Installer, skipRecursive, stripVendor bool) {
if installer.UseCache {
cache.SystemLock()
}
@@ -55,17 +53,9 @@
}
}
- // Delete unused packages
- if installer.DeleteUnused {
- dependency.DeleteUnused(confcopy)
- }
-
- // Vendored cleanup
- // 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(confcopy)
+ err := installer.Export(confcopy)
+ if err != nil {
+ msg.Die("Unable to export dependencies to vendor directory: %s", err)
}
// Write glide.yaml (Why? Godeps/GPM/GB?)
@@ -77,10 +67,6 @@
// from the project. A removed dependency should warn and an added dependency
// should be added to the glide.yaml file. See issue #193.
- if stripVendor {
- confcopy = godep.RemoveGodepSubpackages(confcopy)
- }
-
if !skipRecursive {
// Write lock
hash, err := conf.Hash()
@@ -116,14 +102,6 @@
msg.Warn("Skipping lockfile generation because full dependency tree is not being calculated")
}
- 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)
- }
- }
-
if stripVendor {
msg.Info("Removing nested vendor and Godeps/_workspace directories...")
err := gpath.StripVendor()
diff --git a/dependency/resolver.go b/dependency/resolver.go
index 06dd2dc..5a31ae2 100644
--- a/dependency/resolver.go
+++ b/dependency/resolver.go
@@ -51,6 +51,10 @@
//
// This can be used update a project found in the vendor/ folder.
InVendor(pkg string, addTest bool) error
+
+ // PkgPath is called to find the location locally to scan. This gives the
+ // handler to do things such as use a cached location.
+ PkgPath(pkg string) string
}
// DefaultMissingPackageHandler is the default handler for missing packages.
@@ -84,6 +88,10 @@
return nil
}
+func (d *DefaultMissingPackageHandler) PkgPath(pkg string) string {
+ return pkg
+}
+
// VersionHandler sets the version for a package when found while scanning.
//
// When a package if found it needs to be on the correct version before
@@ -470,7 +478,7 @@
// Here, we want to import the package and see what imports it has.
msg.Debug("Trying to open %s", vdep)
var imps []string
- pkg, err := r.BuildContext.ImportDir(vdep, 0)
+ pkg, err := r.BuildContext.ImportDir(r.Handler.PkgPath(dep), 0)
if err != nil && strings.HasPrefix(err.Error(), "found packages ") {
// If we got here it's because a package and multiple packages
// declared. This is often because of an example with a package
@@ -767,7 +775,7 @@
// FIXME: On error this should try to NotFound to the dependency, and then import
// it again.
var imps []string
- p, err := r.BuildContext.ImportDir(pkg, 0)
+ p, err := r.BuildContext.ImportDir(r.Handler.PkgPath(pkg), 0)
if err != nil && strings.HasPrefix(err.Error(), "found packages ") {
// If we got here it's because a package and multiple packages
// declared. This is often because of an example with a package
diff --git a/glide.go b/glide.go
index 6da33df..f86b491 100644
--- a/glide.go
+++ b/glide.go
@@ -520,30 +520,16 @@
It will create a glide.yaml file from the Godeps data, and then update. This
has no effect if '--no-recursive' is set.
- If you are storing the outside dependencies in your version control system
- (VCS), also known as vendoring, there are a few flags that may be useful.
- The '--update-vendored' flag will cause Glide to update packages when VCS
- information is unavailable. This can be used with the '--strip-vcs' flag which
- will strip VCS data found in the vendor directory. This is useful for
- removing VCS data from transitive dependencies and initial setups. The
- '--strip-vendor' flag will remove any nested 'vendor' folders and
+ The '--strip-vendor' flag will remove any nested 'vendor' folders and
'Godeps/_workspace' folders after an update (along with undoing any Godep
import rewriting). Note, The Godeps specific functionality is deprecated and
will be removed when most Godeps users have migrated to using the vendor
- folder.
-
- Note, Glide detects vendored dependencies. With the '--update-vendored' flag
- Glide will update vendored dependencies leaving them in a vendored state.
- Tertiary dependencies will not be vendored automatically unless the
- '--strip-vcs' flag is used along with it.
-
- By default, packages that are discovered are considered transient, and are
- not stored in the glide.yaml file. The --file=NAME.yaml flag allows you
- to save the discovered dependencies to a YAML file.`,
+ folder.`,
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: "no-recursive, quick",
@@ -558,32 +544,38 @@
Usage: "This will resolve all dependencies for all packages, not just those directly used.",
},
cli.BoolFlag{
- Name: "update-vendored, u",
- Usage: "Update vendored packages (without local VCS repo). Warning, changes will be lost.",
+ Name: "update-vendored, u",
+ Usage: "Update vendored packages (without local VCS repo). Warning, changes will be lost.",
+ Hidden: true,
},
cli.StringFlag{
- Name: "file, f",
- Usage: "Save all of the discovered dependencies to a Glide YAML file.",
+ Name: "file, f",
+ Usage: "Save all of the discovered dependencies to a Glide YAML file.",
+ 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: "resolve-current",
Usage: "Resolve dependencies for only the current system rather than all build modes.",
},
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",
@@ -595,6 +587,28 @@
},
},
Action: func(c *cli.Context) error {
+ 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.")
+ }
+
if c.Bool("strip-vendor") && !c.Bool("strip-vcs") {
msg.Die("--strip-vendor cannot be used without --strip-vcs")
}
@@ -606,16 +620,11 @@
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.ResolveAllFiles = c.Bool("all-dependencies")
installer.Home = c.GlobalString("home")
- installer.DeleteUnused = c.Bool("delete")
installer.ResolveTest = !c.Bool("skip-test")
- action.Update(installer, c.Bool("no-recursive"), c.Bool("strip-vcs"), c.Bool("strip-vendor"))
+ action.Update(installer, c.Bool("no-recursive"), c.Bool("strip-vendor"))
return nil
},
diff --git a/glide.lock b/glide.lock
index 2e8d9f2..5f4169c 100644
--- a/glide.lock
+++ b/glide.lock
@@ -1,5 +1,5 @@
-hash: 67c5571c33bfcb663d32d2b40b9ce1f2a05a3fa2e9f442077277c2782195729c
-updated: 2016-08-11T10:26:47.843225188-04:00
+hash: 84b989218da3e6a1480e6fa95864e838b1e676a970a14d65fffd33cf052a84fd
+updated: 2016-08-11T13:15:29.781819924-04:00
imports:
- name: github.com/codegangsta/cli
version: 1efa31f08b9333f1bd4882d61f9d668a70cd902e
@@ -8,5 +8,5 @@
- name: github.com/Masterminds/vcs
version: fbe9fb6ad5b5f35b3e82a7c21123cfc526cbf895
- name: gopkg.in/yaml.v2
- version: a83829b6f1293c91addabc89d0571c246397bbf4
+ version: e4d366fc3c7938e2958e662b4258c7a89e1f0e3e
testImports: []
diff --git a/repo/installer.go b/repo/installer.go
index c13bfe0..206fb6e 100644
--- a/repo/installer.go
+++ b/repo/installer.go
@@ -266,6 +266,85 @@
return nil
}
+// Export from the cache to the vendor directory
+func (i *Installer) Export(conf *cfg.Config) error {
+ msg.Info("Removing existing vendor dependencies")
+ err := os.RemoveAll(i.VendorPath())
+ if err != nil {
+ return err
+ }
+ msg.Info("Exporting resolved dependencies to vendor directory")
+ done := make(chan struct{}, concurrentWorkers)
+ in := make(chan *cfg.Dependency, concurrentWorkers)
+ var wg sync.WaitGroup
+ var lock sync.Mutex
+ var returnErr error
+
+ for ii := 0; ii < concurrentWorkers; ii++ {
+ go func(ch <-chan *cfg.Dependency) {
+ for {
+ select {
+ case dep := <-ch:
+ loc := dep.Remote()
+ key, err := cache.Key(loc)
+ if err != nil {
+ msg.Die(err.Error())
+ }
+ cache.Lock(key)
+
+ cdir := filepath.Join(cache.Location(), "src", key)
+ repo, err := dep.GetRepo(cdir)
+ if err != nil {
+ msg.Die(err.Error())
+ }
+ msg.Info("--> Exporting %s", dep.Name)
+ if err := repo.ExportDir(filepath.Join(i.VendorPath(), filepath.ToSlash(dep.Name))); err != nil {
+ msg.Err("Export failed for %s: %s\n", dep.Name, err)
+ // Capture the error while making sure the concurrent
+ // operations don't step on each other.
+ lock.Lock()
+ if returnErr == nil {
+ returnErr = err
+ } else {
+ returnErr = cli.NewMultiError(returnErr, err)
+ }
+ lock.Unlock()
+ }
+ cache.Unlock(key)
+ wg.Done()
+ case <-done:
+ return
+ }
+ }
+ }(in)
+ }
+
+ for _, dep := range conf.Imports {
+ if !conf.HasIgnore(dep.Name) {
+ wg.Add(1)
+ in <- dep
+ }
+ }
+
+ if i.ResolveTest {
+ for _, dep := range conf.DevImports {
+ if !conf.HasIgnore(dep.Name) {
+ wg.Add(1)
+ in <- dep
+ }
+ }
+ }
+
+ wg.Wait()
+
+ // Close goroutines setting the version
+ for ii := 0; ii < concurrentWorkers; ii++ {
+ done <- struct{}{}
+ }
+
+ return returnErr
+}
+
// List resolves the complete dependency tree and returns a list of dependencies.
func (i *Installer) List(conf *cfg.Config) []*cfg.Dependency {
base := "."
@@ -364,8 +443,7 @@
msg.Die(err.Error())
}
cache.Lock(key)
- dest := filepath.Join(i.VendorPath(), dep.Name)
- if err := VcsUpdate(dep, dest, i.Home, i.UseCache, i.UseCacheGopath, i.UseGopath, i.Force, i.UpdateVendored, i.Updated); err != nil {
+ if err := VcsUpdate(dep, i.Force, i.Updated); err != nil {
msg.Err("Update failed for %s: %s\n", dep.Name, err)
// Capture the error while making sure the concurrent
// operations don't step on each other.
@@ -492,7 +570,7 @@
m.Config.Imports = append(m.Config.Imports, d)
}
}
- if err := VcsGet(d, dest, m.home, m.cache, m.cacheGopath, m.useGopath); err != nil {
+ if err := VcsGet(d); err != nil {
return false, err
}
return true, nil
@@ -545,8 +623,6 @@
return nil
}
- dest := filepath.Join(m.destination, root)
-
d := m.Config.Imports.Get(root)
if d == nil && addTest {
d = m.Config.DevImports.Get(root)
@@ -567,13 +643,39 @@
}
}
- if err := VcsUpdate(d, dest, m.home, m.cache, m.cacheGopath, m.useGopath, m.force, m.updateVendored, m.updated); err != nil {
+ if err := VcsUpdate(d, m.force, m.updated); err != nil {
return err
}
return nil
}
+// PkgPath resolves the location on the filesystem where the package should be.
+// This handles making sure to use the cache location.
+func (m *MissingPackageHandler) PkgPath(pkg string) string {
+ root, sub := util.NormalizeName(pkg)
+
+ d := m.Config.Imports.Get(root)
+ if d == nil {
+ d = m.Config.DevImports.Get(root)
+ }
+
+ if d == nil {
+ d, _ = m.Use.Get(root)
+
+ if d == nil {
+ d = &cfg.Dependency{Name: root}
+ }
+ }
+
+ key, err := cache.Key(d.Remote())
+ if err != nil {
+ msg.Die("Error generating cache key for %s", d.Name)
+ }
+
+ return filepath.Join(cache.Location(), "src", key, sub)
+}
+
// VersionHandler handles setting the proper version in the VCS.
type VersionHandler struct {
@@ -698,7 +800,7 @@
}
}
- err := VcsVersion(dep, d.Destination)
+ err := VcsVersion(dep)
if err != nil {
msg.Warn("Unable to set version on %s to %s. Err: %s", root, dep.Reference, err)
e = err
diff --git a/repo/set_reference.go b/repo/set_reference.go
index 4363459..26c2e75 100644
--- a/repo/set_reference.go
+++ b/repo/set_reference.go
@@ -5,18 +5,12 @@
"github.com/Masterminds/glide/cfg"
"github.com/Masterminds/glide/msg"
- gpath "github.com/Masterminds/glide/path"
)
// SetReference is a command to set the VCS reference (commit id, tag, etc) for
// a project.
func SetReference(conf *cfg.Config, resolveTest bool) error {
- cwd, err := gpath.Vendor()
- if err != nil {
- return err
- }
-
if len(conf.Imports) == 0 && len(conf.DevImports) == 0 {
msg.Info("No references set.\n")
return nil
@@ -31,7 +25,7 @@
for {
select {
case dep := <-ch:
- if err := VcsVersion(dep, cwd); err != nil {
+ if err := VcsVersion(dep); err != nil {
msg.Err("Failed to set version on %s to %s: %s\n", dep.Name, dep.Reference, err)
}
wg.Done()
diff --git a/repo/vcs.go b/repo/vcs.go
index eacb1c0..6ef9574 100644
--- a/repo/vcs.go
+++ b/repo/vcs.go
@@ -21,7 +21,7 @@
)
// VcsUpdate updates to a particular checkout based on the VCS setting.
-func VcsUpdate(dep *cfg.Dependency, dest, home string, cache, cacheGopath, useGopath, force, updateVendored bool, updated *UpdateTracker) error {
+func VcsUpdate(dep *cfg.Dependency, force bool, updated *UpdateTracker) error {
// If the dependency has already been pinned we can skip it. This is a
// faster path so we don't need to resolve it again.
@@ -43,9 +43,16 @@
return nil
}
+ key, err := cp.Key(dep.Remote())
+ if err != nil {
+ msg.Die("Cache key generation error: %s", err)
+ }
+ location := cp.Location()
+ dest := filepath.Join(location, "src", key)
+
// 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, useGopath); err != nil {
+ if err = VcsGet(dep); err != nil {
msg.Warn("Unable to checkout %s\n", dep.Name)
return err
}
@@ -59,40 +66,18 @@
return err
}
_, err = v.DetectVcsFromFS(dest)
- if updateVendored == false && empty == false && err == v.ErrCannotDetectVCS {
- msg.Warn("%s appears to be a vendored package. Unable to update. Consider the '--update-vendored' flag.\n", dep.Name)
- } else if updateVendored == false && empty == true && err == v.ErrCannotDetectVCS {
- msg.Warn("%s is an empty directory. Fetching a new copy of the dependency.", dep.Name)
+ if empty == true && err == v.ErrCannotDetectVCS {
+ msg.Warn("Cached version of %s is an empty directory. Fetching a new copy of the dependency.", dep.Name)
msg.Debug("Removing empty directory %s", dest)
err := os.RemoveAll(dest)
if err != nil {
return err
}
- if err = VcsGet(dep, dest, home, cache, cacheGopath, useGopath); err != nil {
+ if err = VcsGet(dep); err != nil {
msg.Warn("Unable to checkout %s\n", dep.Name)
return err
}
} else {
-
- if updateVendored == true && empty == false && err == v.ErrCannotDetectVCS {
- // A vendored package, no repo, and updating the vendored packages
- // has been opted into.
- msg.Info("%s is a vendored package. Updating.", dep.Name)
- err = os.RemoveAll(dest)
- if err != nil {
- msg.Err("Unable to update vendored dependency %s.\n", dep.Name)
- return err
- }
- dep.UpdateAsVendored = true
-
- if err = VcsGet(dep, dest, home, cache, cacheGopath, useGopath); err != nil {
- msg.Warn("Unable to checkout %s\n", dep.Name)
- return err
- }
-
- return nil
- }
-
repo, err := dep.GetRepo(dest)
// Tried to checkout a repo to a path that does not work. Either the
@@ -101,19 +86,14 @@
// Warning, any changes in the old location will be deleted.
// TODO: Put dirty checking in on the existing local checkout.
if (err == v.ErrWrongVCS || err == v.ErrWrongRemote) && force == true {
- var newRemote string
- if len(dep.Repository) > 0 {
- newRemote = dep.Repository
- } else {
- newRemote = "https://" + dep.Name
- }
+ newRemote := dep.Remote()
msg.Warn("Replacing %s with contents from %s\n", dep.Name, newRemote)
rerr := os.RemoveAll(dest)
if rerr != nil {
return rerr
}
- if err = VcsGet(dep, dest, home, cache, cacheGopath, useGopath); err != nil {
+ if err = VcsGet(dep); err != nil {
msg.Warn("Unable to checkout %s\n", dep.Name)
return err
}
@@ -128,6 +108,9 @@
return fmt.Errorf("%s contains uncommitted changes. Skipping update", dep.Name)
}
+ if dep.Reference == "" {
+ dep.Reference = defaultBranch(repo)
+ }
// Check if the current version is a tag or commit id. If it is
// and that version is already checked out we can skip updating
// which is faster than going out to the Internet to perform
@@ -162,7 +145,7 @@
}
// VcsVersion set the VCS version for a checkout.
-func VcsVersion(dep *cfg.Dependency, vend string) error {
+func VcsVersion(dep *cfg.Dependency) error {
// If the dependency has already been pinned we can skip it. This is a
// faster path so we don't need to resolve it again.
@@ -171,7 +154,12 @@
return nil
}
- cwd := filepath.Join(vend, dep.Name)
+ key, err := cp.Key(dep.Remote())
+ if err != nil {
+ msg.Die("Cache key generation error: %s", err)
+ }
+ location := cp.Location()
+ cwd := filepath.Join(location, "src", key)
// If there is no reference configured there is nothing to set.
if dep.Reference == "" {
@@ -195,7 +183,7 @@
}
_, err = v.DetectVcsFromFS(cwd)
if empty == false && err == v.ErrCannotDetectVCS {
- msg.Warn("%s appears to be a vendored package. Unable to set new version. Consider the '--update-vendored' flag.\n", dep.Name)
+ return fmt.Errorf("Cache directory missing VCS information for %s", dep.Name)
} else {
repo, err := dep.GetRepo(cwd)
if err != nil {
@@ -261,192 +249,47 @@
// 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, useGopath bool) error {
- // When not skipping the $GOPATH look in it for a copy of the package
- if useGopath {
- // Check if the $GOPATH has a viable version to use and if so copy to vendor
- gps := gpath.Gopaths()
- for _, p := range gps {
- d := filepath.Join(p, "src", dep.Name)
- if _, err := os.Stat(d); err == nil {
- empty, err := gpath.IsDirectoryEmpty(d)
- if empty || err != nil {
- continue
- }
+// VcsGet installs into the cache.
+func VcsGet(dep *cfg.Dependency) error {
- repo, err := dep.GetRepo(d)
- if err != nil {
- continue
- }
-
- // Dirty repos have uncommitted changes.
- if repo.IsDirty() {
- continue
- }
-
- // Having found a repo we copy it to vendor and update it.
- msg.Info("Copying package %s from the GOPATH.", dep.Name)
- msg.Debug("Found %s in GOPATH at %s. Copying to %s", dep.Name, d, dest)
- err = gpath.CopyDir(d, dest)
- if err != nil {
- return err
- }
-
- // Update the repo in the vendor directory
- msg.Debug("Updating %s, now in the vendor path at %s", dep.Name, dest)
- repo, err = dep.GetRepo(dest)
- if err != nil {
- return err
- }
- err = repo.Update()
- if err != nil {
- return err
- }
-
- // If there is no reference set on the dep we try to checkout
- // the default branch.
- if dep.Reference == "" {
- db := defaultBranch(repo, home)
- if db != "" {
- err = repo.UpdateVersion(db)
- if err != nil && msg.Default.IsDebugging {
- msg.Debug("Attempting to set the version on %s to %s failed. Error %s", dep.Name, db, err)
- }
- }
- }
- return nil
- }
- }
+ key, err := cp.Key(dep.Remote())
+ if err != nil {
+ msg.Die("Cache key generation error: %s", err)
}
+ location := cp.Location()
+ d := filepath.Join(location, "src", key)
- // When opting in to cache in the GOPATH attempt to do put a copy there.
- if cacheGopath {
-
- // Since we didn't find an existing copy in the GOPATHs try to clone there.
- gp := gpath.Gopath()
- if gp != "" {
- d := filepath.Join(gp, "src", dep.Name)
- if _, err := os.Stat(d); os.IsNotExist(err) {
- // Empty directory so we checkout out the code here.
- msg.Debug("Retrieving %s to %s before copying to vendor", dep.Name, d)
- repo, err := dep.GetRepo(d)
- if err != nil {
- return err
- }
- repo.Get()
-
- branch := findCurrentBranch(repo)
- if branch != "" {
- // we know the default branch so we can store it in the cache
- loc := dep.Remote()
- key, err := cp.Key(loc)
- if err == nil {
- msg.Debug("Saving default branch for %s", repo.Remote())
- c := cp.RepoInfo{DefaultBranch: branch}
- err = cp.SaveRepoData(key, c)
- if msg.Default.IsDebugging && err == cp.ErrCacheDisabled {
- msg.Debug("Unable to cache default branch because caching is disabled")
- }
- }
- }
-
- msg.Debug("Copying %s from GOPATH at %s to %s", dep.Name, d, dest)
- err = gpath.CopyDir(d, dest)
- if err != nil {
- return err
- }
-
- return nil
- }
- }
- }
-
- // If opting in to caching attempt to put it in the cache folder
- if cache {
- // Check if the cache has a viable version and try to use that.
- loc := dep.Remote()
- key, err := cp.Key(loc)
- if err == nil {
- location := cp.Location()
- d := filepath.Join(location, "src", key)
-
- repo, err := dep.GetRepo(d)
- if err != nil {
- return err
- }
- // If the directory does not exist this is a first cache.
- if _, err = os.Stat(d); os.IsNotExist(err) {
- msg.Debug("Adding %s to the cache for the first time", dep.Name)
- err = repo.Get()
- if err != nil {
- return err
- }
- branch := findCurrentBranch(repo)
- if branch != "" {
- // we know the default branch so we can store it in the cache
- loc := dep.Remote()
- key, err := cp.Key(loc)
- if err == nil {
- msg.Debug("Saving default branch for %s", repo.Remote())
- c := cp.RepoInfo{DefaultBranch: branch}
- err = cp.SaveRepoData(key, c)
- if err == cp.ErrCacheDisabled {
- msg.Debug("Unable to cache default branch because caching is disabled")
- } else if err != nil {
- msg.Debug("Error saving %s to cache. Error: %s", repo.Remote(), err)
- }
- }
- }
-
- } else {
- msg.Debug("Updating %s in the cache", dep.Name)
- err = repo.Update()
- if err != nil {
- return err
- }
- }
-
- msg.Debug("Copying %s from the cache to %s", dep.Name, dest)
- err = gpath.CopyDir(d, dest)
- if err != nil {
- return err
- }
-
- return nil
- }
-
- msg.Warn("Cache key generation error: %s", err)
- }
-
- // If unable to cache pull directly into the vendor/ directory.
- repo, err := dep.GetRepo(dest)
+ repo, err := dep.GetRepo(d)
if err != nil {
return err
}
-
- gerr := repo.Get()
-
- // Attempt to cache the default branch
- if cache {
- if branch := findCurrentBranch(repo); branch != "" {
- // we know the default branch so we can store it in the cache
- loc := dep.Remote()
- key, err := cp.Key(loc)
- if err == nil {
- msg.Debug("Saving default branch for %s", repo.Remote())
- c := cp.RepoInfo{DefaultBranch: branch}
- err = cp.SaveRepoData(key, c)
- if err == cp.ErrCacheDisabled {
- msg.Debug("Unable to cache default branch because caching is disabled")
- } else if err != nil {
- msg.Debug("Error saving %s to cache - Error: %s", repo.Remote(), err)
- }
+ // If the directory does not exist this is a first cache.
+ if _, err = os.Stat(d); os.IsNotExist(err) {
+ msg.Debug("Adding %s to the cache for the first time", dep.Name)
+ err = repo.Get()
+ if err != nil {
+ return err
+ }
+ branch := findCurrentBranch(repo)
+ if branch != "" {
+ msg.Debug("Saving default branch for %s", repo.Remote())
+ c := cp.RepoInfo{DefaultBranch: branch}
+ err = cp.SaveRepoData(key, c)
+ if err == cp.ErrCacheDisabled {
+ msg.Debug("Unable to cache default branch because caching is disabled")
+ } else if err != nil {
+ msg.Debug("Error saving %s to cache. Error: %s", repo.Remote(), err)
}
}
+ } else {
+ msg.Debug("Updating %s in the cache", dep.Name)
+ err = repo.Update()
+ if err != nil {
+ return err
+ }
}
- return gerr
+ return nil
}
// filterArchOs indicates a dependency should be filtered out because it is
@@ -500,7 +343,7 @@
// defaultBranch tries to ascertain the default branch for the given repo.
// Some repos will have multiple branches in them (e.g. Git) while others
// (e.g. Svn) will not.
-func defaultBranch(repo v.Repo, home string) string {
+func defaultBranch(repo v.Repo) string {
// Svn and Bzr use different locations (paths or entire locations)
// for branches so we won't have a default branch.
diff --git a/vendor/gopkg.in/yaml.v2/LICENSE b/vendor/gopkg.in/yaml.v2/LICENSE
index a68e67f..866d74a 100644
--- a/vendor/gopkg.in/yaml.v2/LICENSE
+++ b/vendor/gopkg.in/yaml.v2/LICENSE
@@ -1,188 +1,13 @@
+Copyright 2011-2016 Canonical Ltd.
-Copyright (c) 2011-2014 - Canonical Inc.
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
-This software is licensed under the LGPLv3, included below.
+ http://www.apache.org/licenses/LICENSE-2.0
-As a special exception to the GNU Lesser General Public License version 3
-("LGPL3"), the copyright holders of this Library give you permission to
-convey to a third party a Combined Work that links statically or dynamically
-to this Library without providing any Minimal Corresponding Source or
-Minimal Application Code as set out in 4d or providing the installation
-information set out in section 4e, provided that you comply with the other
-provisions of LGPL3 and provided that you meet, for the Application the
-terms and conditions of the license(s) which apply to the Application.
-
-Except as stated in this special exception, the provisions of LGPL3 will
-continue to comply in full to this Library. If you modify this Library, you
-may apply this exception to your version of this Library, but you are not
-obliged to do so. If you do not wish to do so, delete this exception
-statement from your version. This exception does not (and cannot) modify any
-license terms which apply to the Application, with which you must still
-comply.
-
-
- GNU LESSER GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-
- This version of the GNU Lesser General Public License incorporates
-the terms and conditions of version 3 of the GNU General Public
-License, supplemented by the additional permissions listed below.
-
- 0. Additional Definitions.
-
- As used herein, "this License" refers to version 3 of the GNU Lesser
-General Public License, and the "GNU GPL" refers to version 3 of the GNU
-General Public License.
-
- "The Library" refers to a covered work governed by this License,
-other than an Application or a Combined Work as defined below.
-
- An "Application" is any work that makes use of an interface provided
-by the Library, but which is not otherwise based on the Library.
-Defining a subclass of a class defined by the Library is deemed a mode
-of using an interface provided by the Library.
-
- A "Combined Work" is a work produced by combining or linking an
-Application with the Library. The particular version of the Library
-with which the Combined Work was made is also called the "Linked
-Version".
-
- The "Minimal Corresponding Source" for a Combined Work means the
-Corresponding Source for the Combined Work, excluding any source code
-for portions of the Combined Work that, considered in isolation, are
-based on the Application, and not on the Linked Version.
-
- The "Corresponding Application Code" for a Combined Work means the
-object code and/or source code for the Application, including any data
-and utility programs needed for reproducing the Combined Work from the
-Application, but excluding the System Libraries of the Combined Work.
-
- 1. Exception to Section 3 of the GNU GPL.
-
- You may convey a covered work under sections 3 and 4 of this License
-without being bound by section 3 of the GNU GPL.
-
- 2. Conveying Modified Versions.
-
- If you modify a copy of the Library, and, in your modifications, a
-facility refers to a function or data to be supplied by an Application
-that uses the facility (other than as an argument passed when the
-facility is invoked), then you may convey a copy of the modified
-version:
-
- a) under this License, provided that you make a good faith effort to
- ensure that, in the event an Application does not supply the
- function or data, the facility still operates, and performs
- whatever part of its purpose remains meaningful, or
-
- b) under the GNU GPL, with none of the additional permissions of
- this License applicable to that copy.
-
- 3. Object Code Incorporating Material from Library Header Files.
-
- The object code form of an Application may incorporate material from
-a header file that is part of the Library. You may convey such object
-code under terms of your choice, provided that, if the incorporated
-material is not limited to numerical parameters, data structure
-layouts and accessors, or small macros, inline functions and templates
-(ten or fewer lines in length), you do both of the following:
-
- a) Give prominent notice with each copy of the object code that the
- Library is used in it and that the Library and its use are
- covered by this License.
-
- b) Accompany the object code with a copy of the GNU GPL and this license
- document.
-
- 4. Combined Works.
-
- You may convey a Combined Work under terms of your choice that,
-taken together, effectively do not restrict modification of the
-portions of the Library contained in the Combined Work and reverse
-engineering for debugging such modifications, if you also do each of
-the following:
-
- a) Give prominent notice with each copy of the Combined Work that
- the Library is used in it and that the Library and its use are
- covered by this License.
-
- b) Accompany the Combined Work with a copy of the GNU GPL and this license
- document.
-
- c) For a Combined Work that displays copyright notices during
- execution, include the copyright notice for the Library among
- these notices, as well as a reference directing the user to the
- copies of the GNU GPL and this license document.
-
- d) Do one of the following:
-
- 0) Convey the Minimal Corresponding Source under the terms of this
- License, and the Corresponding Application Code in a form
- suitable for, and under terms that permit, the user to
- recombine or relink the Application with a modified version of
- the Linked Version to produce a modified Combined Work, in the
- manner specified by section 6 of the GNU GPL for conveying
- Corresponding Source.
-
- 1) Use a suitable shared library mechanism for linking with the
- Library. A suitable mechanism is one that (a) uses at run time
- a copy of the Library already present on the user's computer
- system, and (b) will operate properly with a modified version
- of the Library that is interface-compatible with the Linked
- Version.
-
- e) Provide Installation Information, but only if you would otherwise
- be required to provide such information under section 6 of the
- GNU GPL, and only to the extent that such information is
- necessary to install and execute a modified version of the
- Combined Work produced by recombining or relinking the
- Application with a modified version of the Linked Version. (If
- you use option 4d0, the Installation Information must accompany
- the Minimal Corresponding Source and Corresponding Application
- Code. If you use option 4d1, you must provide the Installation
- Information in the manner specified by section 6 of the GNU GPL
- for conveying Corresponding Source.)
-
- 5. Combined Libraries.
-
- You may place library facilities that are a work based on the
-Library side by side in a single library together with other library
-facilities that are not Applications and are not covered by this
-License, and convey such a combined library under terms of your
-choice, if you do both of the following:
-
- a) Accompany the combined library with a copy of the same work based
- on the Library, uncombined with any other library facilities,
- conveyed under the terms of this License.
-
- b) Give prominent notice with the combined library that part of it
- is a work based on the Library, and explaining where to find the
- accompanying uncombined form of the same work.
-
- 6. Revised Versions of the GNU Lesser General Public License.
-
- The Free Software Foundation may publish revised and/or new versions
-of the GNU Lesser General Public License from time to time. Such new
-versions will be similar in spirit to the present version, but may
-differ in detail to address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
-Library as you received it specifies that a certain numbered version
-of the GNU Lesser General Public License "or any later version"
-applies to it, you have the option of following the terms and
-conditions either of that published version or of any later version
-published by the Free Software Foundation. If the Library as you
-received it does not specify a version number of the GNU Lesser
-General Public License, you may choose any version of the GNU Lesser
-General Public License ever published by the Free Software Foundation.
-
- If the Library as you received it specifies that a proxy can decide
-whether future versions of the GNU Lesser General Public License shall
-apply, that proxy's public statement of acceptance of any version is
-permanent authorization for you to choose that version for the
-Library.
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.