question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

version could be wrong when there are more than 1 tags on the commit

See original GitHub issue

when there’s 1.9.0 and 1.10.0 as annotated tags for a commit, 1.9.0 will be returned (probably because it’s the first thing in a list thats sorted alphabetically). it should probably be sorted via semver and always return the larger version instead.

notice that this only happens because of the string “9” is greater than “1”. it’s fine on other versions

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
philgebhardtcommented, Aug 29, 2018

I am running up against this issue as well. And have created https://github.com/palantir/gradle-git-version/pull/103?w=1

If I have 3 subprojects which are versioned independently, I want to ensure my projects keep track of their own versions.

subprojects {
    apply plugin: 'java'
    apply plugin: 'com.palantir.git-version'

    version gitVersion(prefix: "${project.name}-")
}

So, given the following git log:

commit 66aaf3f4d14706dfcd5ef5827638f94da29a1179 (HEAD -> master, tag: foo-0.0.1, tag: baz-0.0.2, tag: bar-0.0.1)
Author: Phil Gebhardt <phil@gremlin.com>
Date:   Wed Aug 29 15:00:00 2018 -0700

    add project

commit 10bc56263aec8c6c8d6cf73e05b6434f778a174e (origin/master, origin/HEAD)
Author: Phil Gebhardt <phil@gremlin.com>
Date:   Wed Aug 29 14:00:00 2018 -0700

    Initial commit
(END)

When I run printVersion for my 3 subprojects, I currently do not get the correct results:

Actual

root@9e2fc3e2a70c:/git-version# ./gradlew printVersion

> Task :services:bar:printVersion
0.0.1

> Task :services:baz:printVersion
66aaf3f

> Task :services:foo:printVersion
66aaf3f


BUILD SUCCESSFUL in 5s
3 actionable tasks: 3 executed

Expected

root@9e2fc3e2a70c:/git-version# ./gradlew printVersion

> Task :services:bar:printVersion
0.0.1

> Task :services:baz:printVersion
0.0.2

> Task :services:foo:printVersion
0.0.1


BUILD SUCCESSFUL in 6s
3 actionable tasks: 3 executed

By moving the prefix filtering logic to mapCommitsToTags, we can acheive the desired result.

1reaction
sixinlicommented, May 28, 2016

I have done some testing and the behaviors of JGit and ‘git describe’ are actually different: one return the first tag and one return the last, but none guarantee that it’s the latest version. So it’s actually not returning what ‘git describe --tags’ would return anyways. I think it would be more useful to support returning the latest version instead of random alph-sorted result.

Thanks, Sixin

On May 27, 2016, at 3:47 PM, Mark Elliot notifications@github.com wrote:

Hm, I’m not sure we can deal with this edge case in a reasonable way. The goal of this (simple) plugin is just to produce a version string equivalent to ‘git describe --tags’. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

Read more comments on GitHub >

github_iconTop Results From Across the Web

setuptools incorrectly picks tag between multiple lightweight ...
Assuming the current comment has multiple tags, setuptools only picks the first one, when it would be better to pick that last one...
Read more >
git describe with two tags on the same commit - Stack Overflow
When I checkout the commit directly, it will be inherently ambiguous. ... Light weight tags appear to use the most recent version as...
Read more >
When should a commit not be version tagged?
If your version control model happens to require that every commit to master be a release, then yes, every commit will need to...
Read more >
Repository Tag task tagging the wrong commit
Hi folks, I am currently working on automated release creation using Bitbucket and Bamboo. Unfortunately the tagging creates some headaches The setup.
Read more >
Better display of tags in commits list view - GitLab.org
And possibly showing more than just one of each before collapsing the rest into ... If there were lots of tags on lots...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found