aboutsummaryrefslogtreecommitdiffstats
path: root/storage
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2017-02-13 23:59:49 +0100
committerMáximo Cuadros <mcuadros@gmail.com>2017-02-13 23:59:49 +0100
commit65351f835dcaa4b50dd44bce7bf3f2e31582dadc (patch)
treec7c5750ace6769c3e983ef5414d1d7dd7e11f3b0 /storage
parentf8b5557875513c5b0aff24bb7b8e28f8f680976f (diff)
downloadgo-git-65351f835dcaa4b50dd44bce7bf3f2e31582dadc.tar.gz
Repository.Init now handles non-standard .git location
Diffstat (limited to 'storage')
-rw-r--r--storage/filesystem/storage.go9
-rw-r--r--storage/filesystem/storage_test.go9
2 files changed, 18 insertions, 0 deletions
diff --git a/storage/filesystem/storage.go b/storage/filesystem/storage.go
index 27dd07f..9895507 100644
--- a/storage/filesystem/storage.go
+++ b/storage/filesystem/storage.go
@@ -11,6 +11,8 @@ import (
// standard git format (this is, the .git directory). Zero values of this type
// are not safe to use, see the NewStorage function below.
type Storage struct {
+ fs billy.Filesystem
+
ObjectStorage
ReferenceStorage
IndexStorage
@@ -28,6 +30,8 @@ func NewStorage(fs billy.Filesystem) (*Storage, error) {
}
return &Storage{
+ fs: fs,
+
ObjectStorage: o,
ReferenceStorage: ReferenceStorage{dir: dir},
IndexStorage: IndexStorage{dir: dir},
@@ -36,3 +40,8 @@ func NewStorage(fs billy.Filesystem) (*Storage, error) {
ModuleStorage: ModuleStorage{dir: dir},
}, nil
}
+
+// Filesystem returns the underlying filesystem
+func (s *Storage) Filesystem() billy.Filesystem {
+ return s.fs
+}
diff --git a/storage/filesystem/storage_test.go b/storage/filesystem/storage_test.go
index e398d22..7300de7 100644
--- a/storage/filesystem/storage_test.go
+++ b/storage/filesystem/storage_test.go
@@ -6,6 +6,7 @@ import (
"srcd.works/go-git.v4/storage/test"
. "gopkg.in/check.v1"
+ "srcd.works/go-billy.v1/memfs"
"srcd.works/go-billy.v1/osfs"
)
@@ -23,3 +24,11 @@ func (s *StorageSuite) SetUpTest(c *C) {
s.BaseStorageSuite = test.NewBaseStorageSuite(storage)
}
+
+func (s *StorageSuite) TestFilesystem(c *C) {
+ fs := memfs.New()
+ storage, err := NewStorage(fs)
+ c.Assert(err, IsNil)
+
+ c.Assert(storage.Filesystem(), Equals, fs)
+}