-
Notifications
You must be signed in to change notification settings - Fork 538
git-describe #736
Comments
This feature will be helpful for us so I started writing something. My idea was to get the log of the
// Opening the repo
cwd , err := filepath.Abs(".")
PanicIfError(err)
r, err := git.PlainOpen(cwd)
PanicIfError(err)
// Head
head, err := r.Head()
PanicIfError(err)
cIter, err := r.Log(&git.LogOptions{
From: head.Hash(),
Order: git.LogOrderCommitterTime,
})
var tag *plumbing.Reference
err = cIter.ForEach(func(c *object.Commit) error {
// Tags
tags, err := r.Tags()
PanicIfError(err)
err = tags.ForEach(func(t *plumbing.Reference) error {
t_hash := t.Hash()
fmt.Printf("%v - %v\n", c.Hash, t_hash)
if bytes.Equal(c.Hash[:] ,t_hash[:]) {
// Found!
tag = t;
return storer.ErrStop
}
// No luck continue searching.
return nil
})
if tag != nil {
// Found
return storer.ErrStop
}
// Not found!
return nil
})
PanicIfError(err) But this is no good solution for repositories where thousands of tags exists.
From here is not hard to create a proto |
Here is my basic implementation of a https://github.com/edupo/semver-cli/blob/master/gitWrapper/git.go I'm not an expert on the matter but if this solution works for others I may do a PR on the go-git. (If I ever understand the million details required to contribute... xD) |
PRs are more than welcome. |
I see in COMPATIBILITY.md that
describe
is neither supported nor unsupported (empty box). I also see that there are no implementation containing that name.I am looking for the equivalent of
git describe --abbrev --dirty --always --tags
.Maybe related: #599 #139
Keep up the amazing work!
The text was updated successfully, but these errors were encountered: