From 84a75d6a00bb3a5c69320ad6c96e85940ed559a9 Mon Sep 17 00:00:00 2001 From: Raja Boujbel Date: Thu, 9 Mar 2023 21:10:15 +0100 Subject: [PATCH] lock: fix pin-depends with with- variables --- master_changes.md | 1 + src/client/opamLockCommand.ml | 16 ++++++++++++++-- tests/reftests/lock.test | 8 +------- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/master_changes.md b/master_changes.md index cbc6f39abd5..87d71250e22 100644 --- a/master_changes.md +++ b/master_changes.md @@ -54,6 +54,7 @@ users) ## Repository ## Lock + * [BUG] Fix `pin-depends` for `with-*` dependencies [#5471 @rjbou - fix #5428] ## Clean diff --git a/src/client/opamLockCommand.ml b/src/client/opamLockCommand.ml index 4f886ef952e..03bf5fe38eb 100644 --- a/src/client/opamLockCommand.ml +++ b/src/client/opamLockCommand.ml @@ -274,8 +274,20 @@ let lock_opam ?(only_direct=false) st opam = (OpamPackage.Name.Set.elements uninstalled_depopts)) in let pin_depends = + let pin_depends = + let is_pin nv = OpamSwitchState.is_pinned st nv.name in + let pins map set = + OpamPackage.Map.fold (fun nv _ set -> + if is_pin nv then OpamPackage.Set.add nv set else set) + map set + in + OpamPackage.Set.filter is_pin all_depends + |> pins dev_depends_map + |> pins test_depends_map + |> pins doc_depends_map + |> pins dev_setup_depends_map + in OpamPackage.Set.fold (fun nv acc -> - if not (OpamSwitchState.is_pinned st nv.name) then acc else match OpamSwitchState.primary_url st nv with | None -> acc | Some u -> @@ -296,7 +308,7 @@ let lock_opam ?(only_direct=false) st opam = | None -> local_warn ()) | _ -> local_warn ()) | None -> (nv, u) :: acc) - all_depends [] + pin_depends [] |> List.rev in opam diff --git a/tests/reftests/lock.test b/tests/reftests/lock.test index 16183fcb681..dacbf966c5b 100644 --- a/tests/reftests/lock.test +++ b/tests/reftests/lock.test @@ -946,12 +946,6 @@ pin-depends: [ ] ### it's here -### -opam-version: "2.0" -### -opam-version: "2.0" -### -opam-version: "2.0" ### opam-version: "2.0" version: "dev" @@ -1013,7 +1007,7 @@ license: "MIT" maintainer: "maint@tain.er" name: "tolock" opam-version: "2.0" -pin-depends: ["a-simple-dep.dev" "git+https://github.com/dbuenzli/cmdliner#f239981642a"] +pin-depends: [["a-doc-dep.dev" "git+https://github.com/dbuenzli/cmdliner#e8f8890fe48"] ["a-simple-dep.dev" "git+https://github.com/dbuenzli/cmdliner#f239981642a"] ["a-test-dep.dev" "git+https://github.com/dbuenzli/cmdliner#1de361182ab"]] synopsis: "A word" version: "dev" ### : Goblint format preserved error :