|
101 | 101 | [nil "--changes-in-table"] |
102 | 102 | [nil "--transitive"]]) |
103 | 103 |
|
| 104 | +(defn- retrieve-artifact-name |
| 105 | + "Retrieve artifact name from artifact string, which may contain version after `@` sign" |
| 106 | + [artifact] |
| 107 | + (let [specific-version (str/split (str artifact) #"@" 2)] |
| 108 | + (if (some? (second specific-version)) (first specific-version) artifact))) |
| 109 | + |
| 110 | +(defn forced-artifacts |
| 111 | + "Forced artifacts are coming from focus param and contain specific version targeted with @" |
| 112 | + [options] |
| 113 | + (->> (:focus options) |
| 114 | + (remove (fn [artifact] |
| 115 | + (-> (str/split (str artifact) #"@" 2) |
| 116 | + second |
| 117 | + not))) |
| 118 | + (map (fn [art] |
| 119 | + (let [[name ver] (str/split (str art) #"@" 2)] |
| 120 | + {:name name, :latest-version ver}))))) |
| 121 | + |
| 122 | +(defn forced-version |
| 123 | + "Returns forced version if exists for `dep`, otherwise nil" |
| 124 | + [dep forced-artifacts] |
| 125 | + (when-let [matching-artifact (some (fn [artifact] |
| 126 | + (when (= (:name artifact) (:name dep)) |
| 127 | + artifact)) |
| 128 | + forced-artifacts)] |
| 129 | + (:latest-version matching-artifact))) |
| 130 | + |
104 | 131 | (defn skip-artifacts? |
105 | 132 | [dep options] |
106 | 133 | (let [exclude-artifacts (set (:exclude options [])) |
107 | | - focus-artifacts (set (:focus options []))] |
| 134 | + focus-artifacts (->> [] |
| 135 | + (:focus options) |
| 136 | + (map retrieve-artifact-name) |
| 137 | + set)] |
108 | 138 | (cond |
109 | 139 | ;; `focus` is prefer than `exclude` |
110 | 140 | (seq focus-artifacts) |
|
151 | 181 | (log/info)))) |
152 | 182 |
|
153 | 183 | (defn- assoc-latest-version |
154 | | - [dep options] |
| 184 | + [dep options forced-artifacts] |
155 | 185 | (let [vers (cond->> (:_versions dep) |
156 | 186 | (not (ver/under-development? (:version dep))) |
157 | 187 | (drop-while ver/under-development?)) |
158 | 188 | vers (remove-skipping-versions vers dep options) |
159 | 189 | latest-version (first vers)] |
160 | | - (assoc dep :latest-version latest-version))) |
| 190 | + (if-let [forced-version (and (seq forced-artifacts) |
| 191 | + (forced-version dep forced-artifacts))] |
| 192 | + (assoc dep :latest-version forced-version :forced? true) |
| 193 | + (assoc dep :latest-version latest-version)))) |
161 | 194 |
|
162 | 195 | (defn- dissoc-no-longer-used-keys |
163 | 196 | [dep] |
|
194 | 227 | _ (report/init-progress uniq-deps options) |
195 | 228 | uniq-deps-with-vers (doall (pmap #(assoc-versions % options) uniq-deps)) |
196 | 229 | _ (report/deinit-progress uniq-deps options) |
197 | | - assoc-latest-version* #(assoc-latest-version % options) |
| 230 | + assoc-latest-version* #(assoc-latest-version % options (forced-artifacts options)) |
198 | 231 | version-checked-deps (->> org-deps |
199 | 232 | (pmap #(complete-versions-by % uniq-deps-with-vers)) |
200 | 233 | (map (comp dissoc-no-longer-used-keys |
|
204 | 237 | (keep :parent) |
205 | 238 | (set))] |
206 | 239 | (->> version-checked-deps |
207 | | - (remove #(and (ver/latest? %) |
| 240 | + (remove #(and (not (:forced? %)) |
| 241 | + (ver/latest? %) |
208 | 242 | (not (contains? parent-dep-names (:name %)))))))) |
209 | 243 |
|
210 | 244 | (defn assoc-changes-url |
|
0 commit comments