Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Perform de-duplication on :repositories.

  • Loading branch information...
commit 037cc9694153d4fa104097b74020c75a7cd853f1 1 parent b5a193d
@technomancy authored
View
23 leiningen-core/src/leiningen/core/project.clj
@@ -66,16 +66,21 @@
:leiningen
:subprocess))}))))
-(defn normalize-repos [{:keys [omit-default-repositories
- repositories] :as project}]
+(defn- de-dupe-repo [[repositories seen?] [id settings]]
+ (let [settings (if (string? settings) {:url settings} settings)]
+ ;; repositories from user profiles can be just credentials, so check :url
+ (if (or (seen? id) (not (:url settings)))
+ [repositories seen?]
+ [(conj repositories [id settings]) (conj seen? id)])))
+
+(defn normalize-repos [{:keys [omit-default-repositories repositories]
+ :as project}]
(assoc project :repositories
- (into (if-not omit-default-repositories
- (:repositories defaults)
- [])
- (for [[id repo] repositories
- ;; user-level :repos entries may contain just credentials
- :when (or (string? repo) (:url repo))]
- [id (if (map? repo) repo {:url repo})]))))
+ (first (reduce de-dupe-repo
+ (if-not omit-default-repositories
+ [(:repositories defaults)
+ (set (map first (:repositories defaults)))]
+ [[] #{}]) repositories))))
(defn- without-version [[id version & other]]
(-> (apply hash-map other)
View
33 leiningen-core/test/leiningen/core/test/project.clj
@@ -35,7 +35,7 @@
[stencil "0.2.0"]],
:twelve 12 ; testing unquote
- :repositories [["central "{:url "http://repo1.maven.org/maven2"}]
+ :repositories [["central" {:url "http://repo1.maven.org/maven2"}]
["clojars" {:url "https://clojars.org/repo/"}]]})
(deftest test-read-project
@@ -82,22 +82,23 @@
(merge-profiles [:blue :qa :tes])
:resource-paths)))
(is (= {:url "http://" :username "u" :password "p"}
- (-> {:repositories {"foo" {:url "http://" :creds :gpg}}
+ (-> {:repositories [["foo" {:url "http://" :creds :gpg}]]
:profiles {:blue {:repositories {"foo"
^:replace {:url "http://"
:username "u"
:password "p"}}}}}
(merge-profiles [:blue :qa :tes])
:repositories
- (get "foo"))))))
+ last last)))))
+;; TODO
(deftest test-merge-profile-deps
(with-redefs [default-profiles test-profiles]
- (let [cp (-> {:resource-paths ["resources"]
- :profiles {:dev {:dependencies
- '[^:displace [org.thnetos/cd-client "0.3.0"]
- [org.clojure/tools.nrepl "0.2.0-beta2"]]}}}
- (merge-profiles [:dev :repl])
+ (let [project {:resource-paths ["resources"]
+ :profiles {:dev {:dependencies
+ '[^:displace [org.thnetos/cd-client "0.3.0"]
+ [org.clojure/tools.nrepl "0.2.0-beta2"]]}}}
+ cp (-> (merge-profiles project [:dev :repl])
(classpath/get-classpath))]
(is (some (partial re-find #"nrepl-0.2.0-beta2") cp))
(is (some (partial re-find #"cd-client-0.3.4") cp)))))
@@ -159,8 +160,8 @@
(deftest test-merge-anon-profiles
(let [expected-result {:A 1 :C 3 :profiles {:a {:A 1}
:b {:B 2}}
- :repositories {"central" {:url "http://repo1.maven.org/maven2"}
- "clojars" {:url "https://clojars.org/repo/"}}
+ :repositories [["central" {:url "http://repo1.maven.org/maven2"}]
+ ["clojars" {:url "https://clojars.org/repo/"}]]
:dependencies [], :compile-path "classes"}]
(is (= expected-result
(-> {:profiles {:a {:A 1} :b {:B 2}}}
@@ -168,8 +169,8 @@
(deftest test-composite-profiles
(let [expected-result {:A '(2 3 1), :B 2, :C 3,
- :repositories {"central" {:url "http://repo1.maven.org/maven2"}
- "clojars" {:url "https://clojars.org/repo/"}}
+ :repositories [["central" {:url "http://repo1.maven.org/maven2"}]
+ ["clojars" {:url "https://clojars.org/repo/"}]]
:dependencies [], :compile-path "classes"}]
(is (= expected-result
(-> {:profiles {:a [:c :b]
@@ -181,8 +182,8 @@
(deftest test-override-default
(let [expected-result {:A 1, :B 2, :C 3
- :repositories {"central" {:url "http://repo1.maven.org/maven2"}
- "clojars" {:url "https://clojars.org/repo/"}}
+ :repositories [["central" {:url "http://repo1.maven.org/maven2"}]
+ ["clojars" {:url "https://clojars.org/repo/"}]]
:dependencies [], :compile-path "classes"}]
(is (= expected-result
(-> {:profiles {:a {:A 1 :B 2}
@@ -196,8 +197,8 @@
(let [expected-result {:A 1 :C 3 :profiles {:a {:A 1}
:b {:B 2}
:c {:C 3}}
- :repositories {"central" {:url "http://repo1.maven.org/maven2"}
- "clojars" {:url "https://clojars.org/repo/"}}
+ :repositories [["central" {:url "http://repo1.maven.org/maven2"}]
+ ["clojars" {:url "https://clojars.org/repo/"}]]
:dependencies [], :compile-path "classes"}]
(is (= expected-result
(-> {:profiles {:a {:A 1}
View
7 src/leiningen/deploy.clj
@@ -31,9 +31,10 @@
[id (assoc settings :username username :password password)]))))
(defn repo-for [project name]
- (let [settings (get (merge {name {:url name}}
- (:repositories project)
- (:deploy-repositories project)) name)]
+ (let [[settings] (for [[id settings] (concat (:deploy-repositories project)
+ (:repositories project)
+ [[name {:url name}]])
+ :when (= id name)] settings)]
(-> [name settings]
(classpath/add-repo-auth)
(add-auth-interactively))))
View
4 todo.org
@@ -14,8 +14,8 @@ See also https://github.com/technomancy/leiningen/issues
- [X] Fast trampolining
- [X] Latest newnew
- [X] Updated :eval-in :classloader
- - [ ] Vector for :repositories
- - [ ] Fix middleware
+ - [X] Vector for :repositories
+ - [X] Fix middleware
** 2.0.0-preview8
- [X] Allow trampoline to work with chaining in do task (#665)
- [X] Store repl port on filesystem (#682)
Please sign in to comment.
Something went wrong with that request. Please try again.