Skip to content

Commit f413dc3

Browse files
committed
replace version compare stuff with version-clj impl
1 parent 3b92f1d commit f413dc3

File tree

3 files changed

+4
-33
lines changed

3 files changed

+4
-33
lines changed

project.clj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
:dependencies [[org.clojure/clojure "1.9.0"]
1010
[me.arrdem/guten-tag "0.1.6"
1111
:exclusions [org.clojure/clojure]]
12+
[version-clj "0.1.2"]
1213
[org.clojure/core.match "0.3.0-alpha4"
1314
:exclusions [org.clojure/clojure]]
1415
[com.cemerick/url "0.1.1"

src/grimoire/api/fs/read.clj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
[grimoire.api.fs.impl :as impl]
1111
[clojure.java.io :as io]
1212
[clojure.string :as string]
13-
[cemerick.url :as url])
13+
[cemerick.url :as url]
14+
[version-clj.core :as v])
1415
(:import [java.io File]))
1516

1617
(defn- f->name [^File f]
@@ -52,7 +53,7 @@
5253
(->> (for [d (reverse (sort (.listFiles handle)))
5354
:when (.isDirectory d)]
5455
(t/->Version artifact (f->name d)))
55-
(sort-by (comp util/clojure-version->cmp-key t/thing->name))
56+
(sort-by t/thing->name v/version-compare)
5657
reverse
5758
succeed)
5859
(fail (str "No such artifact "

src/grimoire/util.clj

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -93,37 +93,6 @@
9393
#(.toLowerCase %)
9494
name))
9595

96-
(defn clojure-version->cmp-key
97-
"Create a comparison key from a Clojure version string, as returned
98-
from function clojure.core/clojure-version. The key is a vector of
99-
integers and strings, and two such keys may be compared via
100-
clojure.core/compare to get the correct relative order of the two
101-
Clojure versions.
102-
103-
Makes simplifying assumption that:
104-
x.y.z-alpha<n> < x.y.z-beta<m> < x.y.z-RC<p> < x.y.z.
105-
106-
Note that this was not the time order of release for some 1.5.0-beta
107-
and 1.5.0-RC releases, historically, as they switched from 1.5.0-RC
108-
releases back to 1.5.0-beta, and then back to 1.5.0-RC again.
109-
Hopefully that will not happen again.
110-
111-
Stolen from AndyF with thanks."
112-
[version-str]
113-
(let [to-long (fn [^String s] (Long/parseLong s))
114-
[v q] (str/split version-str #"-" 2)
115-
[major minor incremental] (mapv to-long (str/split v #"\."))]
116-
[major
117-
(or minor 0)
118-
(or incremental 0)
119-
;; qual1 will be one of "alpha" "beta" "rc", or "zfinal" if
120-
;; version-str is of the form "x.y.z". It will always be
121-
;; lower case so that normal alphabetic order comparison is
122-
;; used, without weirdness of upper case letters being sorted
123-
;; earlier than lower case letters.
124-
(if q (str/lower-case (re-find #"[^\d]+" q)) "zfinal")
125-
(some->> q (re-find #"\d+$") to-long)]))
126-
12796
(defn edn-read-string-with-readers
12897
"Read a string with clojure.edn/read-string and additional reader functions
12998
installed.

0 commit comments

Comments
 (0)