aboutsummaryrefslogtreecommitdiffstats
path: root/storage/memory/storage.go
diff options
context:
space:
mode:
Diffstat (limited to 'storage/memory/storage.go')
-rw-r--r--storage/memory/storage.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/storage/memory/storage.go b/storage/memory/storage.go
index 9b55b1f..92aeec9 100644
--- a/storage/memory/storage.go
+++ b/storage/memory/storage.go
@@ -8,6 +8,7 @@ import (
"srcd.works/go-git.v4/plumbing"
"srcd.works/go-git.v4/plumbing/format/index"
"srcd.works/go-git.v4/plumbing/storer"
+ "srcd.works/go-git.v4/storage"
)
var ErrUnsupportedObjectType = fmt.Errorf("unsupported object type")
@@ -22,6 +23,7 @@ type Storage struct {
ShallowStorage
IndexStorage
ReferenceStorage
+ ModuleStorage
}
// NewStorage returns a new Storage base on memory
@@ -37,6 +39,7 @@ func NewStorage() *Storage {
Blobs: make(map[plumbing.Hash]plumbing.EncodedObject, 0),
Tags: make(map[plumbing.Hash]plumbing.EncodedObject, 0),
},
+ ModuleStorage: make(ModuleStorage, 0),
}
}
@@ -232,3 +235,16 @@ func (s *ShallowStorage) SetShallow(commits []plumbing.Hash) error {
func (s ShallowStorage) Shallow() ([]plumbing.Hash, error) {
return s, nil
}
+
+type ModuleStorage map[string]*Storage
+
+func (s ModuleStorage) Module(name string) (storage.Storer, error) {
+ if m, ok := s[name]; ok {
+ return m, nil
+ }
+
+ m := NewStorage()
+ s[name] = m
+
+ return m, nil
+}