diff options
Diffstat (limited to 'repository.go')
-rw-r--r-- | repository.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/repository.go b/repository.go index f60f910..a553f91 100644 --- a/repository.go +++ b/repository.go @@ -110,6 +110,26 @@ func (r *Repository) Commits() *CommitIter { return NewCommitIter(r, r.Storage.Iter(core.CommitObject)) } +// Tag returns a tag with the given hash. +func (r *Repository) Tag(h core.Hash) (*Tag, error) { + obj, err := r.Storage.Get(h) + if err != nil { + if err == core.ObjectNotFoundErr { + return nil, ObjectNotFoundErr + } + return nil, err + } + + tag := &Tag{r: r} + return tag, tag.Decode(obj) +} + +// Tags returns a TagIter that can step through all of the annotated tags +// in the repository. +func (r *Repository) Tags() *TagIter { + return NewTagIter(r, r.Storage.Iter(core.TagObject)) +} + // Tree return the tree with the given hash func (r *Repository) Tree(h core.Hash) (*Tree, error) { obj, err := r.Storage.Get(h) |