Skip to content

Commit

Permalink
lock: fix pin-depends with with- variables
Browse files Browse the repository at this point in the history
  • Loading branch information
rjbou committed Feb 21, 2025
1 parent fa1e255 commit c6afba3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
1 change: 1 addition & 0 deletions master_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ users)
* Check that the repositories given to `opam repository remove` actually exist [#5014 @kit-ty-kate - fixes #5012]

## Lock
* [BUG] Fix `pin-depends` for `with-*` dependencies [#5471 @rjbou - fix #5428]

## Clean

Expand Down
16 changes: 14 additions & 2 deletions src/client/opamLockCommand.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ->
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/reftests/lock.test
Original file line number Diff line number Diff line change
Expand Up @@ -1315,6 +1315,6 @@ license: "MIT"
maintainer: "[email protected]"
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"

0 comments on commit c6afba3

Please sign in to comment.