Welcome! Please see the About page for a little more info on how this works.

+1 vote
in Clojure CLI by

When Maven versions include pre-releases, find-versions seems to sort correctly:

> clojure -X:deps find-versions :lib hiccup/hiccup
Downloading: hiccup/hiccup/maven-metadata.xml from clojars
{:mvn/version "2.0.0-alpha1"}
{:mvn/version "2.0.0-alpha2"}
{:mvn/version "2.0.0-RC1"}
{:mvn/version "2.0.0-RC2"}
{:mvn/version "2.0.0-RC3"}
{:mvn/version "2.0.0-RC4"}
{:mvn/version "2.0.0-RC5"}
{:mvn/version "2.0.0"}

However, when a library is git-only with tags and pre-releases exist, they seem to be alpha-sorted instead:

> clojure -X:deps find-versions :lib io.github.seancorfield/deps-new
{:git/tag "v0.7.1-rc", :git/sha "5a6168d"}
{:git/tag "v0.8.0", :git/sha "2f96530"}
{:git/tag "v0.8.1", :git/sha "2859baf"}
{:git/tag "v0.9.0", :git/sha "da2f764"}
{:git/tag "v0.9.0-rc", :git/sha "b32e0f2"}
{:git/tag "v0.10.0", :git/sha "20e82f8"}
{:git/tag "v0.10.1", :git/sha "a90029c"}
{:git/tag "v0.10.1-rc", :git/sha "35159b5"}

Those -rc versions should sort before the full release.

1 Answer

+2 votes
by
selected by
 
Best answer

git tags are sorted via:

git tag --sort=v:refname

which treats the tag name as a version. How suffix versions are sorted is dependent on your git config settings. It's possible to change this setting on your machine to consider suffixes before releases with:

git config --global versionsort.suffix -rc

It would be possible to resolve tags to commits and sort based on ancestor comparison but this would affect the performance (possibly a lot). Hard to say what the effect would be without some testing.

by
Nice! I had no idea. That works:

(!2002)-> git config --global versionsort.suffix -rc

(2025-08-10.21:56:45)-(~/clojure)
(!2003)-> clojure -X:deps find-versions :tool new
{:git/tag "v0.7.1", :git/sha "c1e42aa"}
{:git/tag "v0.8.0", :git/sha "2f96530"}
{:git/tag "v0.8.1", :git/sha "2859baf"}
{:git/tag "v0.9.0-rc", :git/sha "b32e0f2"}
{:git/tag "v0.9.0", :git/sha "da2f764"}
{:git/tag "v0.10.0", :git/sha "20e82f8"}
{:git/tag "v0.10.1-rc", :git/sha "35159b5"}
{:git/tag "v0.10.1", :git/sha "a90029c"}

I will dig into that and will update my blog post accordingly.
...