diff options
Diffstat (limited to 'repository.go')
-rw-r--r-- | repository.go | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/repository.go b/repository.go index 8f1aac2..2532c8d 100644 --- a/repository.go +++ b/repository.go @@ -19,7 +19,7 @@ const ( type Repository struct { Remotes map[string]*Remote - Storage *core.RAWObjectStorage + Storage core.ObjectStorage URL string } @@ -92,9 +92,12 @@ func (r *Repository) Pull(remoteName, branch string) (err error) { // Commit return the commit with the given hash func (r *Repository) Commit(h core.Hash) (*Commit, error) { - obj, ok := r.Storage.Get(h) - if !ok { - return nil, ObjectNotFoundErr + obj, err := r.Storage.Get(h) + if err != nil { + if err == core.ObjectNotFoundErr { + return nil, ObjectNotFoundErr + } + return nil, err } commit := &Commit{r: r} @@ -103,22 +106,17 @@ func (r *Repository) Commit(h core.Hash) (*Commit, error) { // Commits decode the objects into commits func (r *Repository) Commits() *CommitIter { - i := NewCommitIter(r) - go func() { - defer i.Close() - for _, obj := range r.Storage.Commits { - i.Add(obj) - } - }() - - return i + return NewCommitIter(r, r.Storage.Iter(core.CommitObject)) } // Tree return the tree with the given hash func (r *Repository) Tree(h core.Hash) (*Tree, error) { - obj, ok := r.Storage.Get(h) - if !ok { - return nil, ObjectNotFoundErr + obj, err := r.Storage.Get(h) + if err != nil { + if err == core.ObjectNotFoundErr { + return nil, ObjectNotFoundErr + } + return nil, err } tree := &Tree{r: r} |