aboutsummaryrefslogtreecommitdiffstats
path: root/storage/filesystem/internal/dotgit/dotgit.go
diff options
context:
space:
mode:
authorSergio Arbeo <serabe@gmail.com>2016-12-19 10:42:14 +0100
committerMáximo Cuadros <mcuadros@gmail.com>2016-12-19 10:42:14 +0100
commit1eb39394cdf09b26eb2f5c98225fb2912980e61f (patch)
tree25e7b370498733aba66688c5d53c29fcef6aa21c /storage/filesystem/internal/dotgit/dotgit.go
parentc9353b2bd7c1cbdf8f78dad6deac64ed2f2ed9eb (diff)
downloadgo-git-1eb39394cdf09b26eb2f5c98225fb2912980e61f.tar.gz
Extract billy (#173)
* Extract billy Billy is a new library directly extracted from go-git. It abstract several storages systems in a filesystem interface. More in github.com/src-d/billy * Fix grouping in imports block * Update billy to v1 * Re-remove fs_implementation example
Diffstat (limited to 'storage/filesystem/internal/dotgit/dotgit.go')
-rw-r--r--storage/filesystem/internal/dotgit/dotgit.go21
1 files changed, 11 insertions, 10 deletions
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])