Skip to content

Commit 9c5baa5

Browse files
committed
install-latest - further refine version release filtering
1 parent b957ba3 commit 9c5baa5

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Changelog
22
===========
33

4+
* next
5+
* `install-latest` - further refine version release filtering
46
* v0.2.7 dcc65e8 on Jun 20, 2022
57
* `install-latest` - improve printing, add no-arg option to install all latest tools
68
* Fix `install-latest` git revision sorting to use semantic rather than lexicographic version sorting

src/clojure/tools/tools/api.clj

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,23 @@
5858
(throw (ex-info (str "Tool not found: " tool) {}))))
5959
:else (throw (ex-info "Missing required args, install-latest requires either :tool or both :lib and :as" (or args {})))))
6060

61+
(defn- release-version?
62+
"Release version does not contain any of:
63+
a, alpha, b, beta, m, milestone, rc, cr, snapshot"
64+
[{:keys [git/tag mvn/version]}]
65+
(let [v (or tag version)]
66+
(when v
67+
(let [vl (str/lower-case v)]
68+
(not
69+
(boolean
70+
(some (fn [s] (str/includes? vl s))
71+
;; check subset of list in docstring as a is in alpha and snapshot, etc
72+
["a" "b" "m" "rc" "cr"])))))))
73+
6174
(defn- install-1
6275
[lib as master-edn]
6376
(let [coord (->> (ext/find-all-versions lib nil master-edn)
64-
(clojure.core/remove #(let [mv (:mvn/version %)] (and mv (str/ends-with? mv "-SNAPSHOT"))))
77+
(filter release-version?)
6578
last)]
6679
(if coord
6780
(let [current (tool/resolve-tool as)]
@@ -80,6 +93,14 @@
8093
Either :tool or both :lib and :as are required to install a single tool.
8194
If neither is provided, install the newest version of all tools.
8295
96+
The latest version is determined by listing the versions in semver order,
97+
filtering out versions with special strings, and choosing the last one.
98+
Special strings that cause a version to be ignored are:
99+
alpha a beta b miletone m rc cr snapshot
100+
101+
It is recommended that Maven tool releases use Maven release version
102+
conventions, and that git tool releases use tags in the format \"vA.B.C\".
103+
83104
Options:
84105
:tool tool-name - currently installed tool
85106
:lib lib-name - mvn lib or git lib with inferrable url
@@ -121,6 +142,10 @@
121142
(install {'org.clojure/data.json {:mvn/version "0.2.0"} :as "json"})
122143
(tool/resolve-tool "json")
123144
(install-latest {:tool "json"})
145+
146+
(filter release-version? (ext/find-all-versions 'io.github.clj-holmes/clj-watson nil master-edn))
147+
(filter release-version? (ext/find-all-versions 'org.clojure/clojure nil master-edn))
148+
(filter release-version? (ext/find-all-versions 'io.github.clojure/data.json nil master-edn))
124149
)
125150

126151
(defn- max-len

0 commit comments

Comments
 (0)