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

Can't clone annotated tags with ReferenceName in Clone #557

Closed
mitchellh opened this issue Aug 24, 2017 · 4 comments
Closed

Can't clone annotated tags with ReferenceName in Clone #557

mitchellh opened this issue Aug 24, 2017 · 4 comments
Labels

Comments

@mitchellh
Copy link

Hi! Great library.

The problem is that given an annotated tag ref, I get an "object not found" error:

repo, err := git.PlainClone(dir, false, &git.CloneOptions{
	URL: "...",
	ReferenceName: plumbing.ReferenceName("refs/tags/v1.0.0"),
})

Where v1.0.0 is an annotated tag (not a lightweight one).

I'm not sure if this is working as intended or not, but I'd expect the library to recognize the commit the annotated tag is pointing to and load that.

Reproducing this is extremely easy:

  1. Create a new git repo
  2. Commit a single file so its not empty
  3. git tag -a "v1.0.0" -m "1.0.0"
  4. Push
  5. Run the code above using that repo's address. It will fail.

Thanks!

@orirawlings
Copy link
Contributor

orirawlings commented Aug 24, 2017

Hey @mitchellh, thanks for reporting this. Also, thank you for lots of other great open source stuff. :)

This appears to be because we are trying to reset the working directory to head.Hash(), which in this case is not a commit object, but the tag object.

https://github.com/src-d/go-git/blob/master/repository.go#L434

orirawlings added a commit to orirawlings/go-git that referenced this issue Aug 24, 2017
orirawlings added a commit to orirawlings/go-git that referenced this issue Aug 24, 2017
orirawlings added a commit to orirawlings/go-git that referenced this issue Aug 25, 2017
orirawlings added a commit to orirawlings/go-git that referenced this issue Aug 25, 2017
mcuadros added a commit that referenced this issue Aug 27, 2017
repository: Resolve commit when cloning annotated tag, fixes #557
@mitchellh
Copy link
Author

Thank you!

@mcuadros
Copy link
Contributor

@mitchellh just playing or any plan for use it in something relevant?

@mitchellh
Copy link
Author

Something quite major! It is relevant to an existing product. I'll comment back here once we announce it. Its still not released. :)

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants