aboutsummaryrefslogtreecommitdiffstats
path: root/storage/filesystem/internal/dotgit/dotgit.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2017-06-18 12:15:40 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2017-06-18 12:15:40 +0200
commitabb9ec0f3efea571b7f19b7391eb7c152c899f45 (patch)
tree703bcd8caf958007e90d6694e5225084b3ddfdb5 /storage/filesystem/internal/dotgit/dotgit.go
parentbf3a92052f715c507ace0cb9f2b7fb358f623abc (diff)
downloadgo-git-abb9ec0f3efea571b7f19b7391eb7c152c899f45.tar.gz
*: upgrade to go-billy.v3, merge
Diffstat (limited to 'storage/filesystem/internal/dotgit/dotgit.go')
-rw-r--r--storage/filesystem/internal/dotgit/dotgit.go25
1 files changed, 12 insertions, 13 deletions
diff --git a/storage/filesystem/internal/dotgit/dotgit.go b/storage/filesystem/internal/dotgit/dotgit.go
index 1af64ab..c48f24c 100644
--- a/storage/filesystem/internal/dotgit/dotgit.go
+++ b/storage/filesystem/internal/dotgit/dotgit.go
@@ -12,7 +12,7 @@ import (
"gopkg.in/src-d/go-git.v4/plumbing"
"gopkg.in/src-d/go-git.v4/utils/ioutil"
- "gopkg.in/src-d/go-billy.v2"
+ "gopkg.in/src-d/go-billy.v3"
)
const (
@@ -357,7 +357,7 @@ func (d *DotGit) rewritePackedRefsWithoutRef(name plumbing.ReferenceName) (err e
return err
}
- tmpPath := tmp.Filename()
+ tmpPath := tmp.Name()
defer ioutil.CheckClose(tmp, &err)
defer d.fs.Remove(tmpPath)
@@ -413,11 +413,11 @@ func (d *DotGit) processLine(line string) (*plumbing.Reference, error) {
}
func (d *DotGit) addRefsFromRefDir(refs *[]*plumbing.Reference) error {
- return d.walkReferencesTree(refs, refsPath)
+ return d.walkReferencesTree(refs, []string{refsPath})
}
-func (d *DotGit) walkReferencesTree(refs *[]*plumbing.Reference, relPath string) error {
- files, err := d.fs.ReadDir(relPath)
+func (d *DotGit) walkReferencesTree(refs *[]*plumbing.Reference, relPath []string) error {
+ files, err := d.fs.ReadDir(d.fs.Join(relPath...))
if err != nil {
if os.IsNotExist(err) {
return nil
@@ -427,7 +427,7 @@ func (d *DotGit) walkReferencesTree(refs *[]*plumbing.Reference, relPath string)
}
for _, f := range files {
- newRelPath := d.fs.Join(relPath, f.Name())
+ newRelPath := append(append([]string(nil), relPath...), f.Name())
if f.IsDir() {
if err = d.walkReferencesTree(refs, newRelPath); err != nil {
return err
@@ -436,7 +436,7 @@ func (d *DotGit) walkReferencesTree(refs *[]*plumbing.Reference, relPath string)
continue
}
- ref, err := d.readReferenceFile(".", newRelPath)
+ ref, err := d.readReferenceFile(".", strings.Join(newRelPath, "/"))
if err != nil {
return err
}
@@ -463,9 +463,8 @@ func (d *DotGit) addRefFromHEAD(refs *[]*plumbing.Reference) error {
return nil
}
-func (d *DotGit) readReferenceFile(refsPath, refFile string) (ref *plumbing.Reference, err error) {
- path := d.fs.Join(refsPath, refFile)
-
+func (d *DotGit) readReferenceFile(path, name string) (ref *plumbing.Reference, err error) {
+ path = d.fs.Join(path, d.fs.Join(strings.Split(name, "/")...))
f, err := d.fs.Open(path)
if err != nil {
return nil, err
@@ -478,12 +477,12 @@ func (d *DotGit) readReferenceFile(refsPath, refFile string) (ref *plumbing.Refe
}
line := strings.TrimSpace(string(b))
- return plumbing.NewReferenceFromStrings(refFile, line), nil
+ return plumbing.NewReferenceFromStrings(name, line), nil
}
// Module return a billy.Filesystem poiting to the module folder
-func (d *DotGit) Module(name string) billy.Filesystem {
- return d.fs.Dir(d.fs.Join(modulePath, name))
+func (d *DotGit) Module(name string) (billy.Filesystem, error) {
+ return d.fs.Chroot(d.fs.Join(modulePath, name))
}
func isHex(s string) bool {