fix repo name should not contain path delims under windows so test won't

fail
all tests pass under windows
This commit is contained in:
AtKaaZ 2013-05-16 05:32:38 +03:00
parent 0277ec3e41
commit 533f4725db
3 changed files with 31 additions and 4 deletions

View file

@ -4,6 +4,7 @@
[clojure.java.io :as io]
[clojure.set :as set]
[leiningen.core.classpath :as classpath]
[leiningen.test.helper :as lthelper]
[leiningen.core.project :as project])
(:import (java.io File)))
@ -52,6 +53,7 @@
:dependencies '[[slamhound "1.3.0"]]
:repositories project/default-repositories}
[newrelic nodisassemble] (classpath-arg p)]
(is (.endsWith newrelic (str "/com/newrelic/agent/java/newrelic-agent"
"/2.18.0/newrelic-agent-2.18.0.jar")))
(is (.endsWith newrelic (lthelper/fix-path-delimiters
(str "/com/newrelic/agent/java/newrelic-agent"
"/2.18.0/newrelic-agent-2.18.0.jar"))))
(is (re-find #"-javaagent:.*nodisassemble-0.1.1.jar=hello" nodisassemble))))

View file

@ -49,10 +49,33 @@
(into-array ["Password: "]))]
[id (assoc settings :username username :password password)]))))
(defn- sanitize-repo-name
"
returns only the last part of the path
ie.
returns: \"lein-custom-repo\"
from input: \"file://C:/Users/user/AppData/Local/Temp//lein-custom-repo\"
reason: the name of the repo must not contain path delimiters ie. \\ or /
because it's used by aether for form filenames like
maven-metadata-lein-custom-repo.xml from the filename maven-metadata.xml
(this is normally seen only under Windows)
"
[name]
(let [idx (.lastIndexOf name "/");java.io.File/separator)
endr (cond (>= idx 0) (subs name (inc idx) (count name))
:else name)]
(when main/*debug*
(println (str "Sanitizing repo name `" name "` into `" endr "`")))
(assert (< (.indexOf endr "\\") 0) "`defn- repo-path` function should've used only / as path delimiters")
(assert (< (.indexOf endr "/") 0) endr)
endr
)
)
(defn repo-for [project name]
(let [settings (merge (get (into {} (:repositories project)) name)
(get (into {} (:deploy-repositories project)) name))]
(-> [name (or settings {:url name})]
(-> [(sanitize-repo-name name) (or settings {:url name})]
(classpath/add-repo-auth)
(add-auth-from-url)
(add-auth-interactively))))

View file

@ -7,7 +7,9 @@
(defn- repo-path
[relative-repo-path]
(format "%s/%s" tmp-dir relative-repo-path))
(clojure.string/replace
(format "%s/%s" tmp-dir relative-repo-path)
"\\" "/")) ;make path delimiters look the same / even under Windows
(defn- repo-url
[absolute-repo-path]