diff options
Diffstat (limited to 'storage/filesystem')
-rw-r--r-- | storage/filesystem/config_test.go | 3 | ||||
-rw-r--r-- | storage/filesystem/internal/dotgit/dotgit.go | 21 | ||||
-rw-r--r-- | storage/filesystem/internal/dotgit/dotgit_test.go | 3 | ||||
-rw-r--r-- | storage/filesystem/internal/dotgit/writers.go | 15 | ||||
-rw-r--r-- | storage/filesystem/internal/dotgit/writers_test.go | 3 | ||||
-rw-r--r-- | storage/filesystem/object.go | 7 | ||||
-rw-r--r-- | storage/filesystem/storage.go | 5 | ||||
-rw-r--r-- | storage/filesystem/storage_test.go | 3 |
8 files changed, 34 insertions, 26 deletions
diff --git a/storage/filesystem/config_test.go b/storage/filesystem/config_test.go index b86eaee..6fbf826 100644 --- a/storage/filesystem/config_test.go +++ b/storage/filesystem/config_test.go @@ -6,7 +6,8 @@ import ( "gopkg.in/src-d/go-git.v4/fixtures" "gopkg.in/src-d/go-git.v4/storage/filesystem/internal/dotgit" - "gopkg.in/src-d/go-git.v4/utils/fs/os" + + "srcd.works/go-billy.v1/os" . "gopkg.in/check.v1" ) diff --git a/storage/filesystem/internal/dotgit/dotgit.go b/storage/filesystem/internal/dotgit/dotgit.go index 3405908..f9763d1 100644 --- a/storage/filesystem/internal/dotgit/dotgit.go +++ b/storage/filesystem/internal/dotgit/dotgit.go @@ -10,7 +10,8 @@ import ( "strings" "gopkg.in/src-d/go-git.v4/plumbing" - "gopkg.in/src-d/go-git.v4/utils/fs" + + "srcd.works/go-billy.v1" ) const ( @@ -51,33 +52,33 @@ var ( // The DotGit type represents a local git repository on disk. This // type is not zero-value-safe, use the New function to initialize it. type DotGit struct { - fs fs.Filesystem + fs billy.Filesystem } // New returns a DotGit value ready to be used. The path argument must // be the absolute path of a git repository directory (e.g. // "/foo/bar/.git"). -func New(fs fs.Filesystem) *DotGit { +func New(fs billy.Filesystem) *DotGit { return &DotGit{fs: fs} } // ConfigWriter returns a file pointer for write to the config file -func (d *DotGit) ConfigWriter() (fs.File, error) { +func (d *DotGit) ConfigWriter() (billy.File, error) { return d.fs.Create(configPath) } // Config returns a file pointer for read to the config file -func (d *DotGit) Config() (fs.File, error) { +func (d *DotGit) Config() (billy.File, error) { return d.fs.Open(configPath) } // ShallowWriter returns a file pointer for write to the shallow file -func (d *DotGit) ShallowWriter() (fs.File, error) { +func (d *DotGit) ShallowWriter() (billy.File, error) { return d.fs.Create(shallowPath) } // Shallow returns a file pointer for read to the shallow file -func (d *DotGit) Shallow() (fs.File, error) { +func (d *DotGit) Shallow() (billy.File, error) { f, err := d.fs.Open(shallowPath) if err != nil { if os.IsNotExist(err) { @@ -124,7 +125,7 @@ func (d *DotGit) ObjectPacks() ([]plumbing.Hash, error) { } // ObjectPack returns a fs.File of the given packfile -func (d *DotGit) ObjectPack(hash plumbing.Hash) (fs.File, error) { +func (d *DotGit) ObjectPack(hash plumbing.Hash) (billy.File, error) { file := d.fs.Join(objectsPath, packPath, fmt.Sprintf("pack-%s.pack", hash.String())) pack, err := d.fs.Open(file) @@ -140,7 +141,7 @@ func (d *DotGit) ObjectPack(hash plumbing.Hash) (fs.File, error) { } // ObjectPackIdx returns a fs.File of the index file for a given packfile -func (d *DotGit) ObjectPackIdx(hash plumbing.Hash) (fs.File, error) { +func (d *DotGit) ObjectPackIdx(hash plumbing.Hash) (billy.File, error) { file := d.fs.Join(objectsPath, packPath, fmt.Sprintf("pack-%s.idx", hash.String())) idx, err := d.fs.Open(file) if err != nil { @@ -190,7 +191,7 @@ func (d *DotGit) Objects() ([]plumbing.Hash, error) { } // Object return a fs.File poiting the object file, if exists -func (d *DotGit) Object(h plumbing.Hash) (fs.File, error) { +func (d *DotGit) Object(h plumbing.Hash) (billy.File, error) { hash := h.String() file := d.fs.Join(objectsPath, hash[0:2], hash[2:40]) diff --git a/storage/filesystem/internal/dotgit/dotgit_test.go b/storage/filesystem/internal/dotgit/dotgit_test.go index b645a85..48f02f0 100644 --- a/storage/filesystem/internal/dotgit/dotgit_test.go +++ b/storage/filesystem/internal/dotgit/dotgit_test.go @@ -9,7 +9,8 @@ import ( "gopkg.in/src-d/go-git.v4/fixtures" "gopkg.in/src-d/go-git.v4/plumbing" - osfs "gopkg.in/src-d/go-git.v4/utils/fs/os" + + osfs "srcd.works/go-billy.v1/os" . "gopkg.in/check.v1" ) diff --git a/storage/filesystem/internal/dotgit/writers.go b/storage/filesystem/internal/dotgit/writers.go index 8e22a39..1cd893d 100644 --- a/storage/filesystem/internal/dotgit/writers.go +++ b/storage/filesystem/internal/dotgit/writers.go @@ -9,7 +9,8 @@ import ( "gopkg.in/src-d/go-git.v4/plumbing/format/idxfile" "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-git.v4/utils/fs" + + "srcd.works/go-billy.v1" ) // PackWriter is a io.Writer that generates the packfile index simultaneously, @@ -21,15 +22,15 @@ import ( type PackWriter struct { Notify func(h plumbing.Hash, i idxfile.Idxfile) - fs fs.Filesystem - fr, fw fs.File + fs billy.Filesystem + fr, fw billy.File synced *syncedReader checksum plumbing.Hash index idxfile.Idxfile result chan error } -func newPackWrite(fs fs.Filesystem) (*PackWriter, error) { +func newPackWrite(fs billy.Filesystem) (*PackWriter, error) { fw, err := fs.TempFile(fs.Join(objectsPath, packPath), "tmp_pack_") if err != nil { return nil, err @@ -248,11 +249,11 @@ func (s *syncedReader) Close() error { type ObjectWriter struct { objfile.Writer - fs fs.Filesystem - f fs.File + fs billy.Filesystem + f billy.File } -func newObjectWriter(fs fs.Filesystem) (*ObjectWriter, error) { +func newObjectWriter(fs billy.Filesystem) (*ObjectWriter, error) { f, err := fs.TempFile(fs.Join(objectsPath, packPath), "tmp_obj_") if err != nil { return nil, err diff --git a/storage/filesystem/internal/dotgit/writers_test.go b/storage/filesystem/internal/dotgit/writers_test.go index c66613a..c546a3a 100644 --- a/storage/filesystem/internal/dotgit/writers_test.go +++ b/storage/filesystem/internal/dotgit/writers_test.go @@ -9,7 +9,8 @@ import ( "strconv" "gopkg.in/src-d/go-git.v4/fixtures" - osfs "gopkg.in/src-d/go-git.v4/utils/fs/os" + + osfs "srcd.works/go-billy.v1/os" . "gopkg.in/check.v1" ) diff --git a/storage/filesystem/object.go b/storage/filesystem/object.go index 836e7f3..e9b5bb7 100644 --- a/storage/filesystem/object.go +++ b/storage/filesystem/object.go @@ -11,7 +11,8 @@ import ( "gopkg.in/src-d/go-git.v4/plumbing/storer" "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-git.v4/utils/fs" + + "srcd.works/go-billy.v1" ) type ObjectStorage struct { @@ -261,7 +262,7 @@ func (i index) Decode(r io.Reader) error { } type packfileIter struct { - f fs.File + f billy.File d *packfile.Decoder t plumbing.ObjectType @@ -270,7 +271,7 @@ type packfileIter struct { total uint32 } -func newPackfileIter(f fs.File, t plumbing.ObjectType, seen map[plumbing.Hash]bool) (storer.EncodedObjectIter, error) { +func newPackfileIter(f billy.File, t plumbing.ObjectType, seen map[plumbing.Hash]bool) (storer.EncodedObjectIter, error) { s := packfile.NewScanner(f) _, total, err := s.Header() if err != nil { diff --git a/storage/filesystem/storage.go b/storage/filesystem/storage.go index e414428..a60d0f4 100644 --- a/storage/filesystem/storage.go +++ b/storage/filesystem/storage.go @@ -3,7 +3,8 @@ package filesystem import ( "gopkg.in/src-d/go-git.v4/storage/filesystem/internal/dotgit" - "gopkg.in/src-d/go-git.v4/utils/fs" + + "srcd.works/go-billy.v1" ) // Storage is an implementation of git.Storer that stores data on disk in the @@ -17,7 +18,7 @@ type Storage struct { } // NewStorage returns a new Storage backed by a given `fs.Filesystem` -func NewStorage(fs fs.Filesystem) (*Storage, error) { +func NewStorage(fs billy.Filesystem) (*Storage, error) { dir := dotgit.New(fs) o, err := newObjectStorage(dir) if err != nil { diff --git a/storage/filesystem/storage_test.go b/storage/filesystem/storage_test.go index c24d5d5..0e8ffb3 100644 --- a/storage/filesystem/storage_test.go +++ b/storage/filesystem/storage_test.go @@ -4,7 +4,8 @@ import ( "testing" "gopkg.in/src-d/go-git.v4/storage/test" - "gopkg.in/src-d/go-git.v4/utils/fs/os" + + "srcd.works/go-billy.v1/os" . "gopkg.in/check.v1" ) |