This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-04-01
Channels
- # announcements (54)
- # asami (3)
- # aws (5)
- # babashka (8)
- # beginners (64)
- # biff (27)
- # calva (11)
- # cider (41)
- # clj-otel (7)
- # cljdoc (72)
- # clojars (20)
- # clojure (159)
- # clojure-austin (3)
- # clojure-europe (143)
- # clojure-italy (1)
- # clojure-nl (5)
- # clojure-norway (3)
- # clojure-uk (3)
- # clojurescript (19)
- # community-development (1)
- # core-typed (5)
- # cursive (3)
- # datalevin (1)
- # datomic (8)
- # emacs (13)
- # fulcro (4)
- # google-cloud (4)
- # honeysql (25)
- # java (1)
- # jobs (1)
- # lambdaisland (3)
- # lsp (121)
- # off-topic (52)
- # other-languages (1)
- # re-frame (3)
- # releases (2)
- # remote-jobs (1)
- # shadow-cljs (36)
- # sql (4)
- # xtdb (36)
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.
@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:
<scm>
<url></url>
<connection>scm:git:</connection>
<developerConnection>scm:git:</developerConnection>
<tag>8937af7f4372c0d2264735ebc1439d0b61030872</tag>
I know you're not supposed to use regexes for that, but:
user=> (second (re-find #"<tag>(.*)</tag>" xml))
"8937af7f4372c0d2264735ebc1439d0b61030872"
yeah, the regex sounds simple, for now 😂 If there is no such way to retrieve that from clojars I think we could try that
You can also download the pom from clojars, https://repo.clojars.org/clj-kondo/clj-kondo/2022.03.10-SNAPSHOT/clj-kondo-2022.03.10-20220331.220408-36.pom
but you still have to parse xml
Assuming you've already found this, but the API docs are a little hard to find, https://github.com/clojars/clojars-web/wiki/Data
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))'
"3973aedec333ef5d773bf6446f36abf8a47cec96"

@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.
https://github.com/clojars/clojars-web/issues/824 I'll try to get to that this weekend
The https://github.com/esuomi/lein-git-revisions 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 🙂