diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2017-02-21 16:07:25 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-21 16:07:25 +0100 |
commit | 867b10692e5f8a34a82cc0a783bdb63e2b5ff398 (patch) | |
tree | 3ddb2f430ee3c958f0650cb7db6a9df44b1e1361 /storage/memory | |
parent | 0b8b8da617d5a077f282e57d0300dc106a604236 (diff) | |
parent | 790fbdaddc3c9a434f2ad97d9eb56db9b6c99495 (diff) | |
download | go-git-867b10692e5f8a34a82cc0a783bdb63e2b5ff398.tar.gz |
Merge pull request #270 from mcuadros/submodules-init
Submodules init and update
Diffstat (limited to 'storage/memory')
-rw-r--r-- | storage/memory/storage.go | 16 |
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 +} |