How to get a gix::Tag from a Reference? #1397
-
I am trying to crawl the tags for a git repository and get information within gix::Tag. However when I try and get an object with something like: // where reference is a gix::Reference with category gix_ref::Category::Tag
let id = gix_reference.id();
// I expect this object should also be a tag
let object = id.object().unwrap();
// this panics as the object is not a tag but is a commit
let tag = object.try_into_tag().unwrap(); How do I actually get a gix::Tag object? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
It's hard to tell what's going on in the snippet as it's all based on what |
Beta Was this translation helpful? Give feedback.
-
Is there an example or could you point me to how I can crawl all tags in a git repo and get the tag info not the commit info? This is what I am currently doing: // open repo
let repo = gix::open(repo_path).unwrap();
// get an iter over references in this repo
let ref_iter = repo.references().unwrap();
// filter to just tags and crawl them
for tag_ref in refs.tags().unwrap() {
// get the category of the reference
if let Some(category) = tag_ref.name().category() {
// filter to just tags which makes me think the object should be a tag?
if category == gix_ref::Category::Tag {
// get this references id
let id = tag_ref.id();
// get this references object which I want to be a Tag but its a Commit
// I understand this also has kind but I can't seem to figure out how to get a Tag
let object = id.object().unwrap();
}
}
} |
Beta Was this translation helpful? Give feedback.
This explains the culprit.