Skip to content

Commit

Permalink
Merge pull request technomancy#1970 from Hardtack/master
Browse files Browse the repository at this point in the history
  • Loading branch information
hypirion committed Sep 20, 2015
2 parents 37e9c8c + d9fa141 commit af387e9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/leiningen/new.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 13 additions & 1 deletion test/leiningen/test/new.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit af387e9

Please sign in to comment.