diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2017-02-12 23:03:30 +0100 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2017-02-12 23:03:30 +0100 |
commit | 498dbf7dc92e288641f1af1acc52704150e8a6c0 (patch) | |
tree | 7be1fab61a2eead003f07249c0312f71decaccf7 /storage/memory/storage.go | |
parent | 87a84b1cb90149cf81e76be46811341a30e4a367 (diff) | |
download | go-git-498dbf7dc92e288641f1af1acc52704150e8a6c0.tar.gz |
storage: git.Storer move to storage.Storer and module handling
Diffstat (limited to 'storage/memory/storage.go')
-rw-r--r-- | storage/memory/storage.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/storage/memory/storage.go b/storage/memory/storage.go index 6cec47b..fa9a4fa 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), } } @@ -227,3 +230,13 @@ 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 _, ok := s[name]; !ok { + s[name] = NewStorage() + } + + return s[name], nil +} |