aboutsummaryrefslogtreecommitdiffstats
path: root/storage/filesystem/reference.go
diff options
context:
space:
mode:
Diffstat (limited to 'storage/filesystem/reference.go')
-rw-r--r--storage/filesystem/reference.go40
1 files changed, 4 insertions, 36 deletions
diff --git a/storage/filesystem/reference.go b/storage/filesystem/reference.go
index ae78efb..b2aa6d9 100644
--- a/storage/filesystem/reference.go
+++ b/storage/filesystem/reference.go
@@ -6,8 +6,7 @@ import (
)
type ReferenceStorage struct {
- dir *dotgit.DotGit
- refs map[core.ReferenceName]*core.Reference
+ dir *dotgit.DotGit
}
func (r *ReferenceStorage) Set(ref *core.Reference) error {
@@ -15,45 +14,14 @@ func (r *ReferenceStorage) Set(ref *core.Reference) error {
}
func (r *ReferenceStorage) Get(n core.ReferenceName) (*core.Reference, error) {
- if err := r.load(); err != nil {
- return nil, err
- }
-
- ref, ok := r.refs[n]
- if !ok {
- return nil, core.ErrReferenceNotFound
- }
-
- return ref, nil
+ return r.dir.Ref(n)
}
func (r *ReferenceStorage) Iter() (core.ReferenceIter, error) {
- if err := r.load(); err != nil {
- return nil, err
- }
-
- var refs []*core.Reference
- for _, ref := range r.refs {
- refs = append(refs, ref)
- }
-
- return core.NewReferenceSliceIter(refs), nil
-}
-
-func (r *ReferenceStorage) load() error {
- if len(r.refs) != 0 {
- return nil
- }
-
refs, err := r.dir.Refs()
if err != nil {
- return err
- }
-
- r.refs = make(map[core.ReferenceName]*core.Reference, 0)
- for _, ref := range refs {
- r.refs[ref.Name()] = ref
+ return nil, err
}
- return nil
+ return core.NewReferenceSliceIter(refs), nil
}