Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upVersions out of order #210
Comments
arrdem
added
the
bug
label
Jul 1, 2015
arrdem
self-assigned this
Jul 1, 2015
arrdem
added this to the 0.4.21 milestone
Jul 1, 2015
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
jafingerhut
Jul 9, 2015
Steal this code if it is useful:
;; (require '[clojure.string :as str])
;; user=> (sort-by f ["1.7.0" "1.5.1" "1.5.0" "1.5.0-beta15" "1.5.0-beta14" "1.7.0-RC2"])
;; ("1.5.0-beta14" "1.5.0-beta15" "1.5.0" "1.5.1" "1.7.0-RC2" "1.7.0")
(defn clojure-version-cmp-key
"Create a comparison key from a Clojure version string, as returned
from function clojure.core/clojure-version. The key is a vector of
integers and strings, and two such keys may be compared via
clojure.core/compare to get the correct relative order of the two
Clojure versions.
Makes simplifying assumption that x.y.z-alpha<n> < x.y.z-beta<m> <
x.y.z-RC<p> < x.y.z. Note that this was not the time order of release
for some 1.5.0-beta and 1.5.0-RC releases, historically, as they
switched from 1.5.0-RC releases back to 1.5.0-beta, and then back to
1.5.0-RC again. Hopefully that will not happen again."
[version-str]
(let [to-long (fn [^String s] (Long/parseLong s))
[major minor x] (str/split version-str #"\." -1)
[incremental x] (str/split x #"-" -1)
;; qual1 will be one of "alpha" "beta" "rc", or "zfinal" if
;; version-str is of the form "x.y.z". It will always be
;; lower case so that normal alphabetic order comparison is
;; used, without weirdness of upper case letters being sorted
;; earlier than lower case letters.
[qual1 qual2] (if x
(if-let [[_ a b] (re-matches #"^(?i)(alpha|beta|rc)(\d+)$" x)]
[(str/lower-case a) (to-long b)]
;; TBD: Is this an error?
)
["zfinal" nil])]
[(to-long major) (to-long minor) (to-long incremental) qual1 qual2]))
jafingerhut
commented
Jul 9, 2015
|
Steal this code if it is useful:
|
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
|
Consider it stolen. Thanks Andy. |
added a commit
that referenced
this issue
Jul 9, 2015
arrdem
closed this
in
d0ae456
Jul 9, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
arrdem commentedJul 1, 2015
http://conj.io/store/v1/org.clojure/clojure
Consequently the "LATEST" tag is going to an old version. Fixit.