aboutsummaryrefslogtreecommitdiffstats
path: root/repository.go
diff options
context:
space:
mode:
Diffstat (limited to 'repository.go')
-rw-r--r--repository.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/repository.go b/repository.go
index cd94159..553703a 100644
--- a/repository.go
+++ b/repository.go
@@ -259,6 +259,16 @@ func (r *Repository) Tree(h core.Hash) (*Tree, error) {
return tree.(*Tree), nil
}
+// Trees decodes the objects into trees
+func (r *Repository) Trees() (*TreeIter, error) {
+ iter, err := r.s.ObjectStorage().Iter(core.TreeObject)
+ if err != nil {
+ return nil, err
+ }
+
+ return NewTreeIter(r, iter), nil
+}
+
// Blob returns the blob with the given hash
func (r *Repository) Blob(h core.Hash) (*Blob, error) {
blob, err := r.Object(core.BlobObject, h)
@@ -269,6 +279,16 @@ func (r *Repository) Blob(h core.Hash) (*Blob, error) {
return blob.(*Blob), nil
}
+// Blobs decodes the objects into blobs
+func (r *Repository) Blobs() (*BlobIter, error) {
+ iter, err := r.s.ObjectStorage().Iter(core.BlobObject)
+ if err != nil {
+ return nil, err
+ }
+
+ return NewBlobIter(r, iter), nil
+}
+
// Tag returns a tag with the given hash.
func (r *Repository) Tag(h core.Hash) (*Tag, error) {
tag, err := r.Object(core.TagObject, h)
@@ -318,6 +338,17 @@ func (r *Repository) Object(t core.ObjectType, h core.Hash) (Object, error) {
}
}
+// Objects returns an ObjectIter that can step through all of the annotated tags
+// in the repository.
+func (r *Repository) Objects() (*ObjectIter, error) {
+ iter, err := r.s.ObjectStorage().Iter(core.AnyObject)
+ if err != nil {
+ return nil, err
+ }
+
+ return NewObjectIter(r, iter), nil
+}
+
// Head returns the reference where HEAD is pointing
func (r *Repository) Head() (*core.Reference, error) {
return core.ResolveReference(r.s.ReferenceStorage(), core.HEAD)