-
Notifications
You must be signed in to change notification settings - Fork 534
ResolveRevision doesn't resolve annotated tags #772
Comments
Can you provide an example repository? Thanks |
Here's a quick way to reproduce this: $ git init
$ git commit --allow-empty -m "Initial commit"
$ git tag -a ann-tag -m "Annotated!"
$ git tag reg-tag And then run: package main
import(
"gopkg.in/src-d/go-git.v4"
"gopkg.in/src-d/go-git.v4/plumbing"
"fmt"
)
func main() {
r, _ := git.PlainOpen(".")
rev1, err := r.ResolveRevision(plumbing.Revision("reg-tag"))
fmt.Println("Regular tag: ", rev1, err)
rev2, err := r.ResolveRevision(plumbing.Revision("ann-tag"))
fmt.Println("Annotated tag: ", rev2, err)
} The output that I see with v4.1.1 is:
|
It seems like |
If you mean the hash of the annotated tag object, then it makes sense, but we also then need a public method to unpeel that to a commit hash. Something similar to |
In the meantime, is there another way to resolve annotated tags using go-git? |
I did some digging and I managed to get it working "kind of". repository.ResolveRevision expects the resolved reference to be a commit. This is the case for lightweight tags. But not at all for annotated tags. replacing
with
seems to do the job. I'm willing to open a PR if this solution seems acceptable for you |
Solved |
Looking through the
revision.Ref
case for the switch statement inResolveRevision
, the tag is resolved, however, callingr.CommitObject
fails with "object not found" error because the resolved commit is not a commit Hash. Seems like one needs to callr.resolveToCommitHash
either beforeCommitObject
or inside of it (depending on the intended API)go-git/repository.go
Lines 914 to 930 in ecda5c1
The text was updated successfully, but these errors were encountered: