This repository was archived by the owner on Sep 11, 2020. It is now read-only.

Description
Hey guys,
I need some advice from you. I want to list all tags from all branches of my repository (equal to the git describe --tags $(git rev-list --tags) command). I'm writing a function that returns the Hash for a given tag name.
I already tried using the References() and Tags() function, but I cannot get it to work.
func (g *Git) getHashByTagName(tagName string) (*plumbing.Reference, error) {
tags, err := g.repo.Tags()
if err != nil {
return nil, err
}
var result *plumbing.Reference
tags.ForEach(func(reference *plumbing.Reference) error {
if tagName == reference.Name().Short() {
result = reference
return errors.New("ErrStop")
}
return nil
})
if result == nil {
return nil, errors.Errorf("Unable to find tag %v", tagName)
}
return result, nil
}
I only get the references for annotated tags, seems like lightweight tags are ignored?
Got:
Want:
v1.0.1
v1.0-2-ga1050a44
v1.0-1-g46b4c026
v1.0