aboutsummaryrefslogtreecommitdiffstats
path: root/storage
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
parentbf3a92052f715c507ace0cb9f2b7fb358f623abc (diff)
downloadgo-git-abb9ec0f3efea571b7f19b7391eb7c152c899f45.tar.gz
*: upgrade to go-billy.v3, merge
Diffstat (limited to 'storage')
-rw-r--r--storage/filesystem/config_test.go2
-rw-r--r--storage/filesystem/internal/dotgit/dotgit.go25
-rw-r--r--storage/filesystem/internal/dotgit/dotgit_test.go27
-rw-r--r--storage/filesystem/internal/dotgit/writers.go10
-rw-r--r--storage/filesystem/internal/dotgit/writers_test.go2
-rw-r--r--storage/filesystem/module.go7
-rw-r--r--storage/filesystem/object.go2
-rw-r--r--storage/filesystem/storage.go2
-rw-r--r--storage/filesystem/storage_test.go4
9 files changed, 43 insertions, 38 deletions
diff --git a/storage/filesystem/config_test.go b/storage/filesystem/config_test.go
index b2879b3..1b812e6 100644
--- a/storage/filesystem/config_test.go
+++ b/storage/filesystem/config_test.go
@@ -8,7 +8,7 @@ import (
"gopkg.in/src-d/go-git.v4/storage/filesystem/internal/dotgit"
. "gopkg.in/check.v1"
- "gopkg.in/src-d/go-billy.v2/osfs"
+ "gopkg.in/src-d/go-billy.v3/osfs"
)
type ConfigSuite struct {
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 {
diff --git a/storage/filesystem/internal/dotgit/dotgit_test.go b/storage/filesystem/internal/dotgit/dotgit_test.go
index f06f908..6151c8f 100644
--- a/storage/filesystem/internal/dotgit/dotgit_test.go
+++ b/storage/filesystem/internal/dotgit/dotgit_test.go
@@ -12,7 +12,7 @@ import (
"gopkg.in/src-d/go-git.v4/plumbing"
. "gopkg.in/check.v1"
- "gopkg.in/src-d/go-billy.v2/osfs"
+ "gopkg.in/src-d/go-billy.v3/osfs"
)
func Test(t *testing.T) { TestingT(t) }
@@ -157,7 +157,7 @@ func (s *SuiteDotGit) TestRemoveRefFromPackedRefs(c *C) {
err := dir.RemoveRef(name)
c.Assert(err, IsNil)
- b, err := ioutil.ReadFile(filepath.Join(fs.Base(), packedRefsPath))
+ b, err := ioutil.ReadFile(filepath.Join(fs.Root(), packedRefsPath))
c.Assert(err, IsNil)
c.Assert(string(b), Equals, ""+
@@ -170,7 +170,7 @@ func (s *SuiteDotGit) TestRemoveRefNonExistent(c *C) {
fs := fixtures.Basic().ByTag(".git").One().DotGit()
dir := New(fs)
- packedRefs := filepath.Join(fs.Base(), packedRefsPath)
+ packedRefs := filepath.Join(fs.Root(), packedRefsPath)
before, err := ioutil.ReadFile(packedRefs)
c.Assert(err, IsNil)
@@ -188,7 +188,7 @@ func (s *SuiteDotGit) TestRemoveRefInvalidPackedRefs(c *C) {
fs := fixtures.Basic().ByTag(".git").One().DotGit()
dir := New(fs)
- packedRefs := filepath.Join(fs.Base(), packedRefsPath)
+ packedRefs := filepath.Join(fs.Root(), packedRefsPath)
brokenContent := "BROKEN STUFF REALLY BROKEN"
err := ioutil.WriteFile(packedRefs, []byte(brokenContent), os.FileMode(0755))
@@ -198,7 +198,7 @@ func (s *SuiteDotGit) TestRemoveRefInvalidPackedRefs(c *C) {
err = dir.RemoveRef(name)
c.Assert(err, NotNil)
- after, err := ioutil.ReadFile(filepath.Join(fs.Base(), packedRefsPath))
+ after, err := ioutil.ReadFile(filepath.Join(fs.Root(), packedRefsPath))
c.Assert(err, IsNil)
c.Assert(brokenContent, Equals, string(after))
@@ -208,7 +208,7 @@ func (s *SuiteDotGit) TestRemoveRefInvalidPackedRefs2(c *C) {
fs := fixtures.Basic().ByTag(".git").One().DotGit()
dir := New(fs)
- packedRefs := filepath.Join(fs.Base(), packedRefsPath)
+ packedRefs := filepath.Join(fs.Root(), packedRefsPath)
brokenContent := strings.Repeat("a", bufio.MaxScanTokenSize*2)
err := ioutil.WriteFile(packedRefs, []byte(brokenContent), os.FileMode(0755))
@@ -218,7 +218,7 @@ func (s *SuiteDotGit) TestRemoveRefInvalidPackedRefs2(c *C) {
err = dir.RemoveRef(name)
c.Assert(err, NotNil)
- after, err := ioutil.ReadFile(filepath.Join(fs.Base(), packedRefsPath))
+ after, err := ioutil.ReadFile(filepath.Join(fs.Root(), packedRefsPath))
c.Assert(err, IsNil)
c.Assert(brokenContent, Equals, string(after))
@@ -243,7 +243,7 @@ func (s *SuiteDotGit) TestConfig(c *C) {
file, err := dir.Config()
c.Assert(err, IsNil)
- c.Assert(filepath.Base(file.Filename()), Equals, "config")
+ c.Assert(filepath.Base(file.Name()), Equals, "config")
}
func (s *SuiteDotGit) TestConfigWriteAndConfig(c *C) {
@@ -362,7 +362,7 @@ func (s *SuiteDotGit) TestObjectPack(c *C) {
pack, err := dir.ObjectPack(f.PackfileHash)
c.Assert(err, IsNil)
- c.Assert(filepath.Ext(pack.Filename()), Equals, ".pack")
+ c.Assert(filepath.Ext(pack.Name()), Equals, ".pack")
}
func (s *SuiteDotGit) TestObjectPackIdx(c *C) {
@@ -372,7 +372,7 @@ func (s *SuiteDotGit) TestObjectPackIdx(c *C) {
idx, err := dir.ObjectPackIdx(f.PackfileHash)
c.Assert(err, IsNil)
- c.Assert(filepath.Ext(idx.Filename()), Equals, ".idx")
+ c.Assert(filepath.Ext(idx.Name()), Equals, ".idx")
}
func (s *SuiteDotGit) TestObjectPackNotFound(c *C) {
@@ -445,7 +445,7 @@ func (s *SuiteDotGit) TestObject(c *C) {
file, err := dir.Object(hash)
c.Assert(err, IsNil)
c.Assert(strings.HasSuffix(
- file.Filename(), "objects/03/db8e1fbe133a480f2867aac478fd866686d69e"),
+ file.Name(), fs.Join("objects", "03", "db8e1fbe133a480f2867aac478fd866686d69e")),
Equals, true,
)
}
@@ -464,6 +464,7 @@ func (s *SuiteDotGit) TestSubmodules(c *C) {
fs := fixtures.ByTag("submodule").One().DotGit()
dir := New(fs)
- m := dir.Module("basic")
- c.Assert(strings.HasSuffix(m.Base(), ".git/module/basic"), Equals, true)
+ m, err := dir.Module("basic")
+ c.Assert(err, IsNil)
+ c.Assert(strings.HasSuffix(m.Root(), m.Join(".git", "module", "basic")), Equals, true)
}
diff --git a/storage/filesystem/internal/dotgit/writers.go b/storage/filesystem/internal/dotgit/writers.go
index 0d2747f..2407c58 100644
--- a/storage/filesystem/internal/dotgit/writers.go
+++ b/storage/filesystem/internal/dotgit/writers.go
@@ -10,7 +10,7 @@ import (
"gopkg.in/src-d/go-git.v4/plumbing/format/objfile"
"gopkg.in/src-d/go-git.v4/plumbing/format/packfile"
- "gopkg.in/src-d/go-billy.v2"
+ "gopkg.in/src-d/go-billy.v3"
)
// PackWriter is a io.Writer that generates the packfile index simultaneously,
@@ -36,7 +36,7 @@ func newPackWrite(fs billy.Filesystem) (*PackWriter, error) {
return nil, err
}
- fr, err := fs.Open(fw.Filename())
+ fr, err := fs.Open(fw.Name())
if err != nil {
return nil, err
}
@@ -130,7 +130,7 @@ func (w *PackWriter) Close() error {
}
func (w *PackWriter) clean() error {
- return w.fs.Remove(w.fw.Filename())
+ return w.fs.Remove(w.fw.Name())
}
func (w *PackWriter) save() error {
@@ -148,7 +148,7 @@ func (w *PackWriter) save() error {
return err
}
- return w.fs.Rename(w.fw.Filename(), fmt.Sprintf("%s.pack", base))
+ return w.fs.Rename(w.fw.Name(), fmt.Sprintf("%s.pack", base))
}
func (w *PackWriter) encodeIdx(writer io.Writer) error {
@@ -282,5 +282,5 @@ func (w *ObjectWriter) save() error {
hash := w.Hash().String()
file := w.fs.Join(objectsPath, hash[0:2], hash[2:40])
- return w.fs.Rename(w.f.Filename(), file)
+ return w.fs.Rename(w.f.Name(), file)
}
diff --git a/storage/filesystem/internal/dotgit/writers_test.go b/storage/filesystem/internal/dotgit/writers_test.go
index e7d7ef9..d2c7b6f 100644
--- a/storage/filesystem/internal/dotgit/writers_test.go
+++ b/storage/filesystem/internal/dotgit/writers_test.go
@@ -11,7 +11,7 @@ import (
"github.com/src-d/go-git-fixtures"
. "gopkg.in/check.v1"
- "gopkg.in/src-d/go-billy.v2/osfs"
+ "gopkg.in/src-d/go-billy.v3/osfs"
)
func (s *SuiteDotGit) TestNewObjectPack(c *C) {
diff --git a/storage/filesystem/module.go b/storage/filesystem/module.go
index 2e469d3..6f3de3f 100644
--- a/storage/filesystem/module.go
+++ b/storage/filesystem/module.go
@@ -10,5 +10,10 @@ type ModuleStorage struct {
}
func (s *ModuleStorage) Module(name string) (storage.Storer, error) {
- return NewStorage(s.dir.Module(name))
+ fs, err := s.dir.Module(name)
+ if err != nil {
+ return nil, err
+ }
+
+ return NewStorage(fs)
}
diff --git a/storage/filesystem/object.go b/storage/filesystem/object.go
index 782b99b..dc88108 100644
--- a/storage/filesystem/object.go
+++ b/storage/filesystem/object.go
@@ -12,7 +12,7 @@ import (
"gopkg.in/src-d/go-git.v4/storage/filesystem/internal/dotgit"
"gopkg.in/src-d/go-git.v4/storage/memory"
- "gopkg.in/src-d/go-billy.v2"
+ "gopkg.in/src-d/go-billy.v3"
)
type ObjectStorage struct {
diff --git a/storage/filesystem/storage.go b/storage/filesystem/storage.go
index 768238e..2c7c107 100644
--- a/storage/filesystem/storage.go
+++ b/storage/filesystem/storage.go
@@ -4,7 +4,7 @@ package filesystem
import (
"gopkg.in/src-d/go-git.v4/storage/filesystem/internal/dotgit"
- "gopkg.in/src-d/go-billy.v2"
+ "gopkg.in/src-d/go-billy.v3"
)
// Storage is an implementation of git.Storer that stores data on disk in the
diff --git a/storage/filesystem/storage_test.go b/storage/filesystem/storage_test.go
index 03d2e86..2ced9dd 100644
--- a/storage/filesystem/storage_test.go
+++ b/storage/filesystem/storage_test.go
@@ -7,8 +7,8 @@ import (
"gopkg.in/src-d/go-git.v4/storage/test"
. "gopkg.in/check.v1"
- "gopkg.in/src-d/go-billy.v2/memfs"
- "gopkg.in/src-d/go-billy.v2/osfs"
+ "gopkg.in/src-d/go-billy.v3/memfs"
+ "gopkg.in/src-d/go-billy.v3/osfs"
)
func Test(t *testing.T) { TestingT(t) }