From 7ba1014b73e4d466320a29f7e3f47fcefe58695d Mon Sep 17 00:00:00 2001 From: Joshua Sjoding Date: Sat, 23 Jan 2016 00:50:29 -0800 Subject: Repository now works against the generic ObjectStore interface --- repository.go | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'repository.go') diff --git a/repository.go b/repository.go index 5deddfb..d0bc103 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 } @@ -100,15 +100,7 @@ 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 -- cgit From d5696c0b75a115001e67025181663b8952b02691 Mon Sep 17 00:00:00 2001 From: Joshua Sjoding Date: Mon, 1 Feb 2016 21:07:28 -0800 Subject: Renamed ObjectStorage Iter function to IterType --- repository.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'repository.go') diff --git a/repository.go b/repository.go index d0bc103..31e5fc7 100644 --- a/repository.go +++ b/repository.go @@ -100,7 +100,7 @@ func (r *Repository) Commit(h core.Hash) (*Commit, error) { // Commits decode the objects into commits func (r *Repository) Commits() *CommitIter { - return NewCommitIter(r, r.Storage.Iter(core.CommitObject)) + return NewCommitIter(r, r.Storage.IterType(core.CommitObject)) } // Tree return the tree with the given hash -- cgit From 43a7081665d3b3754dd26f2b2cc8d0125ee74065 Mon Sep 17 00:00:00 2001 From: Joshua Sjoding Date: Mon, 15 Feb 2016 19:29:08 -0800 Subject: Renamed ObjectStorage.IterType() to Iter() and improved documentation for object iterators --- repository.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'repository.go') diff --git a/repository.go b/repository.go index 31e5fc7..d0bc103 100644 --- a/repository.go +++ b/repository.go @@ -100,7 +100,7 @@ func (r *Repository) Commit(h core.Hash) (*Commit, error) { // Commits decode the objects into commits func (r *Repository) Commits() *CommitIter { - return NewCommitIter(r, r.Storage.IterType(core.CommitObject)) + return NewCommitIter(r, r.Storage.Iter(core.CommitObject)) } // Tree return the tree with the given hash -- cgit From e82d4918b403a641a5295b3f199586b0ab26b15c Mon Sep 17 00:00:00 2001 From: Joshua Sjoding Date: Tue, 16 Feb 2016 03:28:21 -0800 Subject: Functions in core.ObjectStorage interface now return an error --- repository.go | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'repository.go') diff --git a/repository.go b/repository.go index d0bc103..b8920c0 100644 --- a/repository.go +++ b/repository.go @@ -89,9 +89,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} @@ -105,9 +108,12 @@ func (r *Repository) Commits() *CommitIter { // 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} -- cgit