Skip to content

Commit d8bb47b

Browse files
JarrodCTaylorpuredanger
authored andcommitted
make install-latest compatible with non resolvable git urls
1 parent d414101 commit d8bb47b

1 file changed

Lines changed: 19 additions & 15 deletions

File tree

src/clojure/tools/tools/api.clj

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,20 @@
7272
["a" "b" "m" "rc" "cr"])))))))
7373

7474
(defn- install-1
75-
[lib as master-edn]
76-
(let [coord (->> (ext/find-all-versions lib nil master-edn)
77-
(filter release-version?)
78-
last)]
75+
[lib coord as master-edn]
76+
(let [current (tool/resolve-tool as)
77+
coord (or coord (->> (ext/find-all-versions lib (:coord current) master-edn)
78+
(filter release-version?)
79+
last
80+
(merge (:coord current))))]
7981
(if coord
80-
(let [current (tool/resolve-tool as)]
81-
(if (and current (= lib (:lib current)) (zero? (ext/compare-versions lib (:coord current) coord master-edn)))
82-
(println (str as ":") "Skipping, newest installed" (ext/coord-summary lib coord))
83-
(do
84-
(tool/install-tool lib coord as)
85-
(println (str as ":") "Installed" (ext/coord-summary lib coord)
86-
(binding [*print-namespace-maps* false]
87-
(pr-str coord))))))
82+
(if (and current (= lib (:lib current)) (zero? (ext/compare-versions lib (:coord current) coord master-edn)))
83+
(println (str as ":") "Skipping, newest installed" (ext/coord-summary lib coord))
84+
(do
85+
(tool/install-tool lib coord as)
86+
(println (str as ":") "Installed" (ext/coord-summary lib coord)
87+
(binding [*print-namespace-maps* false]
88+
(pr-str coord)))))
8889
(println (str as ":") "Did not find versions for" lib))))
8990

9091
(defn install-latest
@@ -95,6 +96,8 @@
9596
If :lib and :as are provided, the latest version of that lib will be installed
9697
with that tool name, replacing any existing tool by that name.
9798
If no args are provided, install the newest version of all tools.
99+
Optionally :coord may be provided to accommodate privately hosted repositories
100+
or other unresolvable urls.
98101
99102
The latest version is determined by listing the versions in semver order,
100103
filtering out versions with special strings, and choosing the last one.
@@ -108,6 +111,7 @@
108111
Options:
109112
:tool tool-name - currently installed tool
110113
:lib lib-name - mvn lib or git lib with inferrable url
114+
:coord - map (git coords may omit sha)
111115
:as - tool name
112116
113117
Example:
@@ -118,16 +122,16 @@
118122
clj -X:deps find-versions :lib <lib>
119123
clj -Ttools install <lib> <coord> :as tool-name"
120124
[args]
121-
(let [{:keys [lib as]} (parse-install-latest-args args)
125+
(let [{:keys [lib coord as]} (parse-install-latest-args args)
122126
{:keys [root-edn user-edn]} (deps/find-edn-maps)
123127
master-edn (deps/merge-edns [root-edn user-edn])]
124128
(if lib
125-
(install-1 lib as master-edn)
129+
(install-1 lib coord as master-edn)
126130
(run!
127131
(fn [tool-name]
128132
(try
129133
(let [{:keys [lib]} (tool/resolve-tool tool-name)]
130-
(install-1 lib tool-name master-edn))
134+
(install-1 lib coord tool-name master-edn))
131135
(catch Exception e
132136
(println (str tool-name ":") "Failed:" (.getMessage e)))))
133137
(tool/list-tools)))))

0 commit comments

Comments
 (0)