diff options
author | Joshua Sjoding <joshua.sjoding@scjalliance.com> | 2016-02-18 23:28:06 -0800 |
---|---|---|
committer | Joshua Sjoding <joshua.sjoding@scjalliance.com> | 2016-02-18 23:37:11 -0800 |
commit | 5e100bdb6c60e961730af19ab1691a0d3605de12 (patch) | |
tree | 4ae877daab57495e04af3de477d75647a7f1671b /repository.go | |
parent | f23141ac004d672bb8ea22a709b8c3ed1cdb8b89 (diff) | |
download | go-git-5e100bdb6c60e961730af19ab1691a0d3605de12.tar.gz |
Added support for annotated tags
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) |