Last bit of glide chasing, for now This pulls in a fix where cache repos could erroneously error on exportVersionTo() if they were stale, as the method didn't ensure cache repos are synced before erroring out.
diff --git a/glide.lock b/glide.lock index bd87515..fff4efe 100644 --- a/glide.lock +++ b/glide.lock
@@ -1,5 +1,5 @@ hash: e12d18f87508f2f53e2981b52a02ed23d135f59ab90f3afca813727c0685eec0 -updated: 2016-09-15T09:56:26.054743146-04:00 +updated: 2016-09-27T23:50:39.744887915-04:00 imports: - name: github.com/armon/go-radix branch: master @@ -14,8 +14,8 @@ version: v1.8.0 revision: fbe9fb6ad5b5f35b3e82a7c21123cfc526cbf895 - name: github.com/sdboyer/gps - version: v0.11.1 - revision: 507f709c7eb2429371a22cff9f6077630827e450 + branch: master + revision: 44255835bcf52ec1dfacf207dbbb4c1bffe378d0 - name: github.com/termie/go-shutil revision: bcacb06fecaeec8dc42af03c87c6949f4a05c74c - name: gopkg.in/yaml.v2
diff --git a/glide.yaml b/glide.yaml index dcc78aa..2bd32d8 100644 --- a/glide.yaml +++ b/glide.yaml
@@ -18,4 +18,4 @@ - package: github.com/Masterminds/semver branch: 2.x - package: github.com/sdboyer/gps - version: ^0.11.0 + branch: master
diff --git a/vendor/github.com/sdboyer/gps/source.go b/vendor/github.com/sdboyer/gps/source.go index 75265d9..81cb3be 100644 --- a/vendor/github.com/sdboyer/gps/source.go +++ b/vendor/github.com/sdboyer/gps/source.go
@@ -100,7 +100,7 @@ if !bs.crepo.synced { err = bs.crepo.r.Update() if err != nil { - return nil, nil, fmt.Errorf("could not fetch latest updates into repository") + return nil, nil, fmt.Errorf("failed fetching latest updates with err: %s", err.Error()) } bs.crepo.synced = true }
diff --git a/vendor/github.com/sdboyer/gps/vcs_source.go b/vendor/github.com/sdboyer/gps/vcs_source.go index 338a2da..91089ca 100644 --- a/vendor/github.com/sdboyer/gps/vcs_source.go +++ b/vendor/github.com/sdboyer/gps/vcs_source.go
@@ -30,50 +30,68 @@ } func (s *gitSource) exportVersionTo(v Version, to string) error { - s.crepo.mut.Lock() - defer s.crepo.mut.Unlock() - + // Get away without syncing local, if we can r := s.crepo.r - if !r.CheckLocal() { - err := r.Get() - if err != nil { - return fmt.Errorf("failed to clone repo from %s", r.Remote()) - } - } - // Back up original index - idx, bak := filepath.Join(r.LocalPath(), ".git", "index"), filepath.Join(r.LocalPath(), ".git", "origindex") - err := os.Rename(idx, bak) - if err != nil { + // ...but local repo does have to at least exist + if err := s.ensureCacheExistence(); err != nil { return err } - // TODO(sdboyer) could have an err here - defer os.Rename(bak, idx) + do := func() error { + s.crepo.mut.Lock() + defer s.crepo.mut.Unlock() - vstr := v.String() - if rv, ok := v.(PairedVersion); ok { - vstr = rv.Underlying().String() + // Back up original index + idx, bak := filepath.Join(r.LocalPath(), ".git", "index"), filepath.Join(r.LocalPath(), ".git", "origindex") + err := os.Rename(idx, bak) + if err != nil { + return err + } + + // could have an err here...but it's hard to imagine how? + defer os.Rename(bak, idx) + + vstr := v.String() + if rv, ok := v.(PairedVersion); ok { + vstr = rv.Underlying().String() + } + + out, err := r.RunFromDir("git", "read-tree", vstr) + if err != nil { + return fmt.Errorf("%s: %s", out, err) + } + + // Ensure we have exactly one trailing slash + to = strings.TrimSuffix(to, string(os.PathSeparator)) + string(os.PathSeparator) + // Checkout from our temporary index to the desired target location on + // disk; now it's git's job to make it fast. + // + // Sadly, this approach *does* also write out vendor dirs. There doesn't + // appear to be a way to make checkout-index respect sparse checkout + // rules (-a supercedes it). The alternative is using plain checkout, + // though we have a bunch of housekeeping to do to set up, then tear + // down, the sparse checkout controls, as well as restore the original + // index and HEAD. + out, err = r.RunFromDir("git", "checkout-index", "-a", "--prefix="+to) + if err != nil { + return fmt.Errorf("%s: %s", out, err) + } + return nil } - out, err := r.RunFromDir("git", "read-tree", vstr) - if err != nil { - return fmt.Errorf("%s: %s", out, err) + err := do() + if err != nil && !s.crepo.synced { + // If there was an err, and the repo cache is stale, it might've been + // beacuse we were missing the rev/ref. Try syncing, then run the export + // op again. + err = s.syncLocal() + if err != nil { + return err + } + err = do() } - // Ensure we have exactly one trailing slash - to = strings.TrimSuffix(to, string(os.PathSeparator)) + string(os.PathSeparator) - // Checkout from our temporary index to the desired target location on disk; - // now it's git's job to make it fast. Sadly, this approach *does* also - // write out vendor dirs. There doesn't appear to be a way to make - // checkout-index respect sparse checkout rules (-a supercedes it); - // the alternative is using plain checkout, though we have a bunch of - // housekeeping to do to set up, then tear down, the sparse checkout - // controls, as well as restore the original index and HEAD. - out, err = r.RunFromDir("git", "checkout-index", "-a", "--prefix="+to) - if err != nil { - return fmt.Errorf("%s: %s", out, err) - } - return nil + return err } func (s *gitSource) listVersions() (vlist []Version, err error) { @@ -502,10 +520,19 @@ r.mut.Lock() defer r.mut.Unlock() + // TODO(sdboyer) sloppy - this update may not be necessary + if !r.synced { + err := r.r.Update() + if err != nil { + return fmt.Errorf("err on attempting to update repo: %s", err.Error()) + } + } + + r.r.UpdateVersion(v.String()) + // TODO(sdboyer) This is a dumb, slow approach, but we're punting on making // these fast for now because git is the OVERWHELMING case (it's handled in // its own method) - r.r.UpdateVersion(v.String()) cfg := &shutil.CopyTreeOptions{ Symlinks: true,
diff --git a/vendor/gopkg.in/yaml.v2/README.md b/vendor/gopkg.in/yaml.v2/README.md index 7b8bd86..1884de6 100644 --- a/vendor/gopkg.in/yaml.v2/README.md +++ b/vendor/gopkg.in/yaml.v2/README.md
@@ -42,7 +42,7 @@ License ------- -The yaml package is licensed under the LGPL with an exception that allows it to be linked statically. Please see the LICENSE file for details. +The yaml package is licensed under the Apache License 2.0. Please see the LICENSE file for details. Example