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

Pick the higher version if there are multiple on the current commit #162

Merged
merged 1 commit into from
Sep 13, 2018

Conversation

mpollmeier
Copy link
Contributor

Currently, when there are multiple version tags on the current commit, one is picked semi-randomly. I say semi because it's actually deterministic, but it doesn't quite make sense. Anyway, if there are two tags, it typically picks the highest one, unless the last segment has more decimals (e.g. it picks 0.9 over 0.10, and 0.99 over 0.100).

git tag v0.1
git tag v0.2
sbt 'show version' #0.2

git tag v0.9
git tag v0.10
sbt 'show version' #0.9

Technically you could say "who cares, it's the same commit anyway", but if you then publish the package to the jar repository, you have to pick the right one, and that's the one with the higher version - because the latter one is likely already published and it will fail on the attempt to re-publish.

Note: the sort algo is short enough to copy it (and it's tests) into this repo, if you want to save a dependency. That jar has zero dependencies though (not even scala). I use it for another project and just published it to maven central.

Currently, when there are multiple version tags on the current commit, one is picked semi-randomly. I say `semi` because it's actually deterministic, but it doesn't quite make sense. Anyway, if there are two tags, it typically picks the highest one, unless the last segment has more decimals (e.g. it picks `0.9` over `0.10`, and `0.99` over `0.100`).
```
git tag v0.1
git tag v0.2
sbt 'show version' #0.2

git tag v0.9
git tag v0.10
sbt 'show version' #0.9
```
Technically you could say "who cares, it's the same commit anyway", but if you then publish the package to the jar repository, you have to pick the right one, and that's the one with the higher version - because the latter one is likely already published and it will fail on the attempt to re-publish.

Note: the [sort algo](https://github.com/mpollmeier/versionsort/blob/master/src/main/java/versionsort/VersionHelper.java) is short enough to copy it (and it's tests) into this repo, if you want to save a dependency. That jar has zero dependencies though (not even scala). I use it for another project and just published it to maven central.
@mpollmeier
Copy link
Contributor Author

Note: the package is on sonatype and will be synchronised to maven central shortly, which will greenify travis.

@mpollmeier
Copy link
Contributor Author

@dwijnand I was hoping this one's straightforward...?

Copy link
Member

@dwijnand dwijnand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks straightforward, indeed! Thank you!

@dwijnand
Copy link
Member

Restarting CI to pickup the jar.

@mpollmeier
Copy link
Contributor Author

Thanks! Would be great if you could release a new version with this, we're running into this bug once a week :)

@dwijnand
Copy link
Member

I can suggest https://github.com/dwijnand/sbt-dynver, where I've got Travis CI publishing. But you'd have to resolve the same issue: sbt/sbt-dynver#48 ;-)

@dwijnand dwijnand merged commit f8caf93 into sbt:master Sep 13, 2018
@mpollmeier
Copy link
Contributor Author

Soooo.. any chance we can get an 1.0.1 release with this included?

While we're at suggesting, this would help you to not have requests like this in the future :)
https://github.com/ShiftLeftSecurity/sbt-ci-release-early

@haavardw
Copy link

haavardw commented Nov 1, 2018

I think this should be reverted. Does not work when the conflict is not on HEAD.

@mpollmeier
Copy link
Contributor Author

@haavardw what's a use case for not working with HEAD?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants