Skip to content

Commit

Permalink
Ensure the right versions of packages are used when simulating pinning
Browse files Browse the repository at this point in the history
Co-authored-by: Kate <kit-ty-kate@outlook.com>
  • Loading branch information
rjbou and kit-ty-kate committed Mar 1, 2025
1 parent e2a3500 commit 31218de
Show file tree
Hide file tree
Showing 3 changed files with 20 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 @@ -51,6 +51,7 @@ users)
* [BUG] Stop double pin of packages located in ./opam/opam [#6343 @kit-ty-kate - fix #6342]
* Don't ask confirmation when pinning an unknown package (absent from repositories) [#6309 @kit-ty-kate @rjbou - fix #3199]
* [BUG] Do not ask to install pin-depends twice [#6375 @kit-ty-kate - fix #6374]
* [BUG] Ensure the right versions of packages are used when simulating pinning [#6256 @rjbou @kit-ty-kate - fix #6248 #6379]

## List

Expand Down
13 changes: 11 additions & 2 deletions src/client/opamAuxCommands.ml
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,15 @@ let simulate_local_pinnings ?quiet ?(for_view=false) st to_pin =
} in
st, local_packages

let simulate_pinned_atoms pins atoms =
List.map (function
| (_name, Some _) as a -> a
| (name, None) as a ->
match OpamPackage.package_of_name_opt pins name with
| Some pkg -> (name, Some (`Eq, OpamPackage.version pkg))
| None -> a)
atoms

let simulate_autopin st ?quiet ?(for_view=false) ?locked ?recurse ?subpath
atom_or_local_list =
let atoms, to_pin, obsolete_pins, already_pinned_set =
Expand Down Expand Up @@ -424,7 +433,7 @@ let simulate_autopin st ?quiet ?(for_view=false) ?locked ?recurse ?subpath
OpamConsole.note "The following may not reflect the above pinnings (their \
package definitions are not available at this stage)";
OpamConsole.msg "\n"));
st, atoms
st, simulate_pinned_atoms pins atoms

let autopin st ?(simulate=false) ?quiet ?locked ?recurse ?subpath
atom_or_local_list =
Expand Down Expand Up @@ -494,7 +503,7 @@ let autopin st ?(simulate=false) ?quiet ?locked ?recurse ?subpath
else
OpamUpdate.dev_packages st ~working_dir:OpamPackage.Set.empty already_pinned
in
st, atoms
st, simulate_pinned_atoms pins atoms

let check_and_revert_sandboxing root config =
let sdbx_wrappers =
Expand Down
15 changes: 8 additions & 7 deletions tests/reftests/pin.test
Original file line number Diff line number Diff line change
Expand Up @@ -1060,10 +1060,11 @@ opam-version: "2.0"
### <pkg:deps-sim.2>
opam-version: "2.0"
### opam install ./sim --deps-only
The following actions will be performed:
=== install 1 package
- install deps-sim 1 [required by sim]

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> installed deps-sim.1
Done.
[ERROR] Package conflict!
* Incompatible packages:
- (invariant) -> simcomp
- deps-of-sim
You can temporarily relax the switch invariant with `--update-invariant'

No solution found, exiting
# Return code 20 #

0 comments on commit 31218de

Please sign in to comment.