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 Oct 16, 2024
1 parent 89e23f0 commit 84a75d6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
1 change: 1 addition & 0 deletions master_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ users)
## Repository

## 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
8 changes: 1 addition & 7 deletions tests/reftests/lock.test
Original file line number Diff line number Diff line change
Expand Up @@ -946,12 +946,6 @@ pin-depends: [
]
### <tolock/content>
it's here
### <pin:a-simple-dep/a-simple-dep.opam>
opam-version: "2.0"
### <pin:a-test-dep/a-test-dep.opam>
opam-version: "2.0"
### <pin:a-doc-dep/a-doc-dep.opam>
opam-version: "2.0"
### <pin:opam>
opam-version: "2.0"
version: "dev"
Expand Down Expand Up @@ -1013,7 +1007,7 @@ 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"
### : Goblint format preserved error :
Expand Down

0 comments on commit 84a75d6

Please sign in to comment.