Fork me on GitHub

Is it possible given a snapshot-derived version like clj-kondo/clj-kondo 2022.03.10-20220331.135739-32 to retrieve the git SHA for this version, e.g. through the clojars API?


The reason I'm asking, and this may be a case of x-y problem, is that clojure-lsp regularly uses -SNAPSHOT versions for their (binary) (with the date substituted for -SNAPSHOT as clojars produces it after deploying) builds as often they contain analysis updates that are interesting for them, but not so interesting for end users of clj-kondo (so I'd rather wait with a release for that audience until it has more features). I write a file like CLJ_KONDO_VERSION so tools can grab that from the classpath and know the version, but since this has 2022.03-10-SNAPSHOT inside clojure-lsp, it's not very specific. So maybe retrieving the SHA using the 2022.03.10-20220331.135739-32 -shaped version can help.

🙏 1

@UKFSJSM38 clojure-lsp could include this:

(def kondo-pom (slurp (io/resource "META-INF/maven/clj-kondo/clj-kondo/pom.xml")))


and then grab the tag from there:



and then print this in the version output


oh, xml parsing no 🏃 😂


yeah, that would probably be a valid workaround


I know you're not supposed to use regexes for that, but:

user=> (second (re-find #"<tag>(.*)</tag>" xml))

🤯 1

yeah, the regex sounds simple, for now 😂 If there is no such way to retrieve that from clojars I think we could try that


but you still have to parse xml


Assuming you've already found this, but the API docs are a little hard to find,


Here is a babashka script which prints the github sha given a clojure-lsp version:

$ bb -e "(babashka.deps/add-deps '{:deps {com.github.clojure-lsp/clojure-lsp {:mvn/version \"2022.03.31-20.00.20\"}}})" -e "(require '[ :as io])" -e '(def xml (slurp (io/resource "META-INF/maven/clj-kondo/clj-kondo/pom.xml")))' -e '(second (re-find #"<tag>(.*)</tag>" xml))'

babashka 1

since bb also contains, you could also do it properly


@U7RJTCH6J Thanks, I always forget where to find those


Clojars doesn't extract the SHAs and store them, so no API call will return them currently. Clojars also doesn't treat individual SNAPSHOT deploys as different versions at the db level - that individuality only exists in the repo. As far as the API docs being hard to find, I agree, that's not great. Maybe I should add a link to them in the footer? Also open to other suggestions.


yes, footer would be great


that's where I tried to find them

tcrawley20:04:58 I'll try to get to that this weekend

❤️ 2

The plugin I made recently deals a lot with stuff like this; in fact the primary reason it has the ability to generate metadata file into project resources is to include the git metadata into generated JAR. Now this is very tangential to what is being asked, of course, but my point is - I wrote the plugin on purpose in such a way that the Leiningen plugin integration is largely irrelevant after the first few lines. Feels free to grab whatever you need from there if you find it useful 🙂