Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Detect stable versions without patchver (e.g. "1.2"), and treat them …

…as potential updates
  • Loading branch information...
commit cf1f1d83d0f02ce5c4946f6f56ef2f9ebf6c68f9 1 parent f617d0c
@purcell purcell authored committed
Showing with 11 additions and 1 deletion.
  1. +6 −0 src/lein_search/core.clj
  2. +5 −1 test/lein_search/core_test.clj
View
6 src/lein_search/core.clj
@@ -136,6 +136,12 @@ the supplied zip move function each time"
:else (.compareTo v1-suffix v2-suffix)))
version-comparison)))
+(defn latest-stable [versions]
+ (->> versions
+ (sort-by identity compare-versions)
+ (filter (partial re-find #"^(\d+).(\d+)(?:.(\d+))?$"))
+ last))
+
;;; Clojars cache
View
6 test/lein_search/core_test.clj
@@ -41,4 +41,8 @@
:dependencies 'a "1.2")))
(is (= '(defproject "whatever" :dev-dependencies [[a "1.2"]])
(update-artifact '(defproject "whatever" :dev-dependencies [[a "1.1"]])
- :dev-dependencies 'a "1.2"))))
+ :dev-dependencies 'a "1.2"))))
+
+(deftest picking-latest-stable-version
+ (is (= "1.2.0" (latest-stable ["1.1.8" "1.2.0-RC" "1.2.0" "1.2.1-SNAPSHOT"])))
+ (is (= "1.2" (latest-stable ["1.1" "1.2-RC" "1.2" "1.2-SNAPSHOT"]))))
Please sign in to comment.
Something went wrong with that request. Please try again.