Skip to content

Commit 1d1424a

Browse files
committed
During dep expansion, only consider lib to be omitted if all parent paths to root are omitted
1 parent db20e5c commit 1d1424a

File tree

3 files changed

+29
-24
lines changed

3 files changed

+29
-24
lines changed

Diff for: CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ Changelog
33

44
*Also see [Tools and installer changelog](https://github.com/clojure/brew-install/blob/1.12.0/CHANGELOG.md)*
55

6+
* next on Feb 7, 2025
7+
* During dep expansion, only consider lib to be omitted if all parent paths to root are omitted
68
* 0.22.1480 on Feb 6, 2025
79
* Rollback modifying the dep expansion for same version children
810
* 0.22.1476 on Feb 6, 2025

Diff for: src/main/clojure/clojure/tools/deps.clj

+15-10
Original file line numberDiff line numberDiff line change
@@ -283,16 +283,21 @@
283283
"Is any part of the parent path missing from the selected lib/versions?
284284
This can happen if a newer version was found, orphaning previously selected children."
285285
[vmap parent-path]
286-
(when (seq parent-path)
287-
(loop [path parent-path]
288-
(if (seq path)
289-
(let [lib (last path)
290-
check-path (vec (butlast path))
291-
{:keys [paths select]} (get vmap lib)]
292-
(if (contains? (get paths select) check-path)
293-
(recur check-path)
294-
true))
295-
false))))
286+
(loop [path parent-path
287+
more-paths nil]
288+
(if (seq path)
289+
(let [lib (last path)
290+
check-path (vec (butlast path))
291+
{:keys [paths select]} (get vmap lib)]
292+
(let [paths-to-selected (get paths select)]
293+
(if (contains? paths-to-selected check-path)
294+
;; add alternative paths to root that include the selected lib
295+
(recur check-path (concat more-paths (remove #(= % check-path) paths-to-selected)))
296+
(if (seq more-paths)
297+
;; consider alternative paths before considering lib to be omitted
298+
(recur (first more-paths) (rest more-paths))
299+
true))))
300+
false)))
296301

297302
(defn- deselect-orphans
298303
"For the given paths, deselect any libs whose only selected version paths are in omitted-paths"

Diff for: src/test/clojure/clojure/tools/deps/test_deps.clj

+12-14
Original file line numberDiff line numberDiff line change
@@ -240,20 +240,18 @@
240240
;; +b1 -> +e1 -> +c1 -> +d1
241241
;; -> +h2 -> c1 -> d1
242242
;; h2 supersedes previous h1, but need to ensure d1 is included via c1 somewhere
243-
;(deftest test-cut-previously-selected-child-3
244-
; (fkn/with-libs {'ex/a {{:fkn/version "1"} [['ex/h {:fkn/version "1"}]]}
245-
; 'ex/b {{:fkn/version "1"} [['ex/e {:fkn/version "1"}]]}
246-
; 'ex/c {{:fkn/version "1"} [['ex/d {:fkn/version "1"}]]}
247-
; 'ex/d {{:fkn/version "1"} nil}
248-
; 'ex/e {{:fkn/version "1"} [['ex/c {:fkn/version "1"}] ['ex/h {:fkn/version "2"}]]}
249-
; 'ex/h {{:fkn/version "1"} [['ex/c {:fkn/version "1"}]]
250-
; {:fkn/version "2"} [['ex/c {:fkn/version "1"}]]}}
251-
; (is (= {:a "1", :b "1", :c "1", :d "1", :e "1", :h "2"}
252-
; (let [res (deps/resolve-deps {:deps {'ex/a {:fkn/version "1"}
253-
; 'ex/b {:fkn/version "1"}}} {:threads 1})]
254-
; (libs->lib-ver res))))))
255-
;
256-
;(comment (test-cut-previously-selected-child-3) )
243+
(deftest test-cut-previously-selected-child-3
244+
(fkn/with-libs {'ex/a {{:fkn/version "1"} [['ex/h {:fkn/version "1"}]]}
245+
'ex/b {{:fkn/version "1"} [['ex/e {:fkn/version "1"}]]}
246+
'ex/c {{:fkn/version "1"} [['ex/d {:fkn/version "1"}]]}
247+
'ex/d {{:fkn/version "1"} nil}
248+
'ex/e {{:fkn/version "1"} [['ex/c {:fkn/version "1"}] ['ex/h {:fkn/version "2"}]]}
249+
'ex/h {{:fkn/version "1"} [['ex/c {:fkn/version "1"}]]
250+
{:fkn/version "2"} [['ex/c {:fkn/version "1"}]]}}
251+
(is (= {:a "1", :b "1", :c "1", :d "1", :e "1", :h "2"}
252+
(let [res (deps/resolve-deps {:deps {'ex/a {:fkn/version "1"}
253+
'ex/b {:fkn/version "1"}}} nil)]
254+
(libs->lib-ver res))))))
257255

258256
;; +a -> +b -> -x2 -> -y2 -> -z2
259257
;; -> +c -> +d -> +x3 -> +y2 -> +z2

0 commit comments

Comments
 (0)