Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

log does not work with annotated tags #71

Closed
tschulte opened this issue Jul 31, 2015 · 3 comments
Closed

log does not work with annotated tags #71

tschulte opened this issue Jul 31, 2015 · 3 comments
Milestone

Comments

@tschulte
Copy link

given: 'a git repository with a tag'

cd /tmp/
mkdir grgit
cd grgit/
git init
git commit --allow-empty -m '.'
git tag -m '.' v1.0.0

when: 'I have the following groovy script'

@Grab('org.ajoberstar:grgit:1.3.0')
import org.ajoberstar.grgit.Grgit
def grgit = Grgit.open()
grgit.log {
    range 'v1.0.0', 'HEAD'
}.each { println it.id }

an Exception is thrown

Caught: org.eclipse.jgit.errors.IncorrectObjectTypeException: Object 6b291bb71a1b2372323fdfbb24a408b62248303e is not a commit.

I tried

def grgit = Grgit.open()
grgit.log {
    def tag = JGitUtil.resolveTag(grgit.repository, 'v1.0.0')
    range tag, 'HEAD'
}.each { println it.id }

without success.

It does only work, if I change it to

def grgit = Grgit.open()
grgit.log {
    def tag = JGitUtil.resolveTag(grgit.repository, 'v1.0.0')
    range tag.commit, 'HEAD'
}.each { println it.id }

There is no problem with simple (non-annotated) tags.

tschulte added a commit to tschulte/gradle-semantic-release-plugin that referenced this issue Jul 31, 2015
@ajoberstar
Copy link
Owner

I think I've seen that before, but I didn't look too much into it. The workaround I was using was:

grgit.log {
  range 'v1.0.0^{commit}', 'HEAD'
}.each { println it.id }

Does that work for you? Either way I'll probably add it to the wishlist, just to see if there's a better way to handle this.

@ajoberstar ajoberstar added this to the wishlist milestone Aug 1, 2015
@tschulte
Copy link
Author

tschulte commented Aug 1, 2015

Yes, that does the trick. I was not aware of that syntax. As Lothar Matthäus would say: Again what learned. (https://www.youtube.com/watch?v=fH55rwgx1nY)

But I had to write range "${previousVersionString}^{commit}".toString(), 'HEAD' in my code, because ResolveService.toRevisionString does not support GStrings. Maybe that's another enhancement ticket?

tschulte added a commit to tschulte/gradle-semantic-release-plugin that referenced this issue Aug 1, 2015
@ajoberstar
Copy link
Owner

Yes, the GString stuff should be enhanced (#72).

I'm guessing there's some trick to resolving the right type of object (in the grgit code) to use in the log that would avoid needing to add the ^{commit} at the end.

@ajoberstar ajoberstar modified the milestones: 1.4.0, wishlist Aug 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants