From 5192dda1cc974c14bb626b6414a9ae7947d84f2c Mon Sep 17 00:00:00 2001 From: GunWoo Choi <6566gun@gmail.com> Date: Sat, 29 Aug 2015 02:12:33 +0900 Subject: [PATCH 1/2] Add value of `:mirrors` in user profiles to fake project. --- src/leiningen/new.clj | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/leiningen/new.clj b/src/leiningen/new.clj index 4d24fa3c..a2eed553 100644 --- a/src/leiningen/new.clj +++ b/src/leiningen/new.clj @@ -17,12 +17,15 @@ template-version (cond *template-version* *template-version* *use-snapshots?* "(0.0.0,)" :else "RELEASE") + user-profiles (:user (user/profiles)) repositories (reduce (:reduce (meta project/default-repositories)) project/default-repositories - (-> (user/profiles) :user :plugin-repositories))] - {:templates [[template-symbol template-version]] - :repositories repositories})) + (:plugin-repositories user-profiles)) + {:keys [mirrors] :as extra-user-profiles} user-profiles] + (conj {:templates [[template-symbol template-version]] + :repositories repositories} + extra-user-profiles))) (defn resolve-remote-template [name sym] (try (cp/resolve-dependencies :templates (fake-project name) :add-classpath? true) From d9fa1416297a984b500f614d87cf36dde5b8c543 Mon Sep 17 00:00:00 2001 From: GunWoo Choi <6566gun@gmail.com> Date: Sun, 30 Aug 2015 16:59:55 +0900 Subject: [PATCH 2/2] Add test for `new template` with mirror settings --- test/leiningen/test/new.clj | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/test/leiningen/test/new.clj b/test/leiningen/test/new.clj index e31c2588..bf207317 100644 --- a/test/leiningen/test/new.clj +++ b/test/leiningen/test/new.clj @@ -7,7 +7,7 @@ (deftest test-new-with-just-project-name (leiningen.new/new nil "test-new-proj") (is (= #{"README.md" "project.clj" "resources" "src" "core.clj" "test" - "doc" "intro.md" "test_new_proj" "core_test.clj" ".gitignore" + "doc" "intro.md" "test_new_proj" "core_test.clj" ".gitignore" ".hgignore" "LICENSE"} (set (map (memfn getName) (rest (file-seq (file "test-new-proj"))))))) (delete-file-recursively (file "test-new-proj") :silently)) @@ -58,6 +58,18 @@ (with-redefs [leiningen.new/resolve-remote-template (constantly false)] (abort-msg leiningen.new/new nil "zzz" "my-zzz"))))) +(deftest test-new-with-nonexistent-template-in-mirrors + (is (nil? + (with-redefs + [leiningen.core.user/profiles + (constantly {:user + {:mirrors + {"clojars" "https://clojars.example.com" + "central" "http://central.exmaple.com"}}})] + (let [name "luminus" + sym (symbol (str "leiningen.new." name))] + (leiningen.new/resolve-remote-template name sym)))))) + (deftest test-new-with-*-jure-project-name (is (re-find #"names such as clojure .* are not allowed"