Support ordering repositories, fixes #268
This commit is contained in:
parent
ad39cec761
commit
9d7c8b52b0
2 changed files with 27 additions and 8 deletions
|
@ -129,7 +129,7 @@ Warning: alpha; subject to change."
|
||||||
"clojars" {:url "http://clojars.org/repo/"}})
|
"clojars" {:url "http://clojars.org/repo/"}})
|
||||||
|
|
||||||
;; you can't remove or omit "central", you can only disable it;
|
;; you can't remove or omit "central", you can only disable it;
|
||||||
;; maven/maven-ant-tasks adds it implicitly, and will continue to
|
;; maven/maven-ant-tasks adds it implicitly, and will continue to
|
||||||
;; report it in the list of checked repositories, even though it's
|
;; report it in the list of checked repositories, even though it's
|
||||||
;; not been consulted. The URL will hopefully be clear enough to users.
|
;; not been consulted. The URL will hopefully be clear enough to users.
|
||||||
(def disabled-central-repo {"central" {:url "http://disabled-central"
|
(def disabled-central-repo {"central" {:url "http://disabled-central"
|
||||||
|
@ -146,13 +146,15 @@ Warning: alpha; subject to change."
|
||||||
(defn repositories-for
|
(defn repositories-for
|
||||||
"Return a map of repositories including or excluding defaults."
|
"Return a map of repositories including or excluding defaults."
|
||||||
[project]
|
[project]
|
||||||
(merge (when-not (:omit-default-repositories project)
|
(let [project-repos (for [[id settings] (:repositories project)]
|
||||||
default-repos)
|
[id (init-settings id settings)])
|
||||||
(let [repositories (merge (and (:omit-default-repositories project)
|
all-repos (concat
|
||||||
disabled-central-repo)
|
(into []
|
||||||
(:repositories project))]
|
(if (:omit-default-repositories project)
|
||||||
(into {} (for [[id settings] repositories]
|
disabled-central-repo
|
||||||
[id (init-settings id settings)])))))
|
default-repos))
|
||||||
|
project-repos)]
|
||||||
|
(apply array-map (mapcat identity all-repos))))
|
||||||
|
|
||||||
(defn exit
|
(defn exit
|
||||||
"Call System/exit. Defined as a function so that rebinding is possible."
|
"Call System/exit. Defined as a function so that rebinding is possible."
|
||||||
|
|
|
@ -56,3 +56,20 @@
|
||||||
(is (= ["http://disabled-central" "http://repo-1-url"]
|
(is (= ["http://disabled-central" "http://repo-1-url"]
|
||||||
(map :url (vals repos))))))
|
(map :url (vals repos))))))
|
||||||
|
|
||||||
|
(deftest test-repositories-for-including-defaults
|
||||||
|
(let [repos (repositories-for sample-project)]
|
||||||
|
(is (get repos "central"))
|
||||||
|
(is (get repos "clojars"))
|
||||||
|
(is (get repos "snapshots"))))
|
||||||
|
|
||||||
|
(deftest test-repositories-for-many-repos-ordered
|
||||||
|
(let [repo-names (map #(str "repo-" %) (range 20))
|
||||||
|
fake-url-ify #(str % "-url")
|
||||||
|
repos (repositories-for
|
||||||
|
{:omit-default-repositories true
|
||||||
|
:repositories (map #(vector % (fake-url-ify %))
|
||||||
|
repo-names)})]
|
||||||
|
(is (= clojure.lang.PersistentArrayMap (class repos)))
|
||||||
|
(is (= {:url "repo-11-url"} (get repos "repo-11")))
|
||||||
|
(is (= (map fake-url-ify repo-names) (rest (map :url (vals repos)))))))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue