Skip to content

Commit

Permalink
Fix "opam install <local_dir>" not updating pinned packages' metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
kit-ty-kate committed Oct 22, 2024
1 parent 9130a7a commit 79a2867
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 8 deletions.
1 change: 1 addition & 0 deletions master_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ users)
## Actions

## Install
* Fix `opam install <local_dir>` not updating and storing pinned packages' metadata [#6209 @kit-ty-kate - fix #5567]

## Build (package)

Expand Down
9 changes: 3 additions & 6 deletions src/client/opamAuxCommands.ml
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ let resolve_locals ?(quiet=false) ?locked ?recurse ?subpath
(OpamUrl.to_string nf.pin.pin_url))
duplicates)

let autopin_aux st ?quiet ?(for_view=false) ?recurse ?subpath ?locked
let autopin_aux st ?quiet ?recurse ?subpath ?locked
atom_or_local_list =
let to_pin, atoms =
resolve_locals ?quiet ?recurse ?subpath ?locked atom_or_local_list
Expand Down Expand Up @@ -303,10 +303,7 @@ let autopin_aux st ?quiet ?(for_view=false) ?recurse ?subpath ?locked
| _ -> false)
| None -> false)
&&
(* For `opam show`, we need to check does the opam file changed to
perform a simulated pin if so *)
(not for_view ||
match
(match
OpamSwitchState.opam_opt st pinned_pkg,
OpamFile.OPAM.read_opt nf.pin.pin_file
with
Expand Down Expand Up @@ -396,7 +393,7 @@ let simulate_local_pinnings ?quiet ?(for_view=false) st to_pin =
let simulate_autopin st ?quiet ?(for_view=false) ?locked ?recurse ?subpath
atom_or_local_list =
let atoms, to_pin, obsolete_pins, already_pinned_set =
autopin_aux st ?quiet ~for_view ?recurse ?subpath ?locked atom_or_local_list
autopin_aux st ?quiet ?recurse ?subpath ?locked atom_or_local_list
in
if to_pin = [] then st, atoms else
let st =
Expand Down
1 change: 1 addition & 0 deletions tests/reftests/lock.test
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,7 @@ The following actions will be performed:
-> removed tolock.1
Done.
### opam install ./tolock --locked
tolock is now pinned to git+file://${BASEDIR}/tolock#master (version 1)
[tolock.1] synchronised (no changes)
The following actions will be performed:
=== install 1 package
Expand Down
24 changes: 22 additions & 2 deletions tests/reftests/pin.test
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ The following actions will be performed:
-> removed nip.dev
Done.
### opam install ./nip
nip is now pinned to file://${BASEDIR}/nip (version dev)
[nip.dev] synchronised (no changes)
The following actions will be performed:
=== install 1 package
Expand Down Expand Up @@ -443,9 +444,21 @@ opam-version: "2.0"
depends: "dependency" {= "1"}
### ::: behaviour when the package is not pinned
### opam install ./pin-change
pin-change is now pinned to git+file://${BASEDIR}/pin-change#master (version dev)
[NOTE] Ignoring uncommitted changes in ${BASEDIR}/pin-change (`--working-dir' not specified or specified with no argument).
[pin-change.dev] synchronised (no changes)
[NOTE] Package pin-change is already installed (current version is dev).
The following actions will be performed:
=== recompile 1 package
- recompile pin-change dev (pinned)
=== install 1 package
- install dependency 1 [required by pin-change]

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> installed dependency.1
-> retrieved pin-change.dev (no changes)
-> removed pin-change.dev
-> installed pin-change.dev
Done.
### <pin:pin-change/opam>
opam-version: "2.0"
depends: "dependency" {= "2"}
Expand All @@ -466,6 +479,13 @@ depends: "dependency" {= "3"}
### opam install --deps-only ./pin-change/opam
[NOTE] Ignoring uncommitted changes in ${BASEDIR}/pin-change (`--working-dir' not specified or specified with no argument).
[pin-change.dev] synchronised (no changes)
Nothing to do.
The following actions will be performed:
=== upgrade 1 package
- upgrade dependency 1 to 3 [required by pin-change]

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> removed dependency.1
-> installed dependency.3
Done.
### opam pin
pin-change.dev (uninstalled) git git+file://${BASEDIR}/pin-change#master

0 comments on commit 79a2867

Please sign in to comment.