Skip to content

Commit

Permalink
pin: only display a "is now pinned to" message if the package is not …
Browse files Browse the repository at this point in the history
…already pinned
  • Loading branch information
kit-ty-kate committed Feb 25, 2025
1 parent 7dc9d23 commit ffc0d4f
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 20 deletions.
10 changes: 6 additions & 4 deletions src/client/opamPinCommand.ml
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,8 @@ and source_pin
registered in the current switch."
(OpamPackage.Name.to_string name);

(match OpamStd.Option.map OpamFile.URL.url cur_urlf, target_url with
let cur_urlf_url = OpamStd.Option.map OpamFile.URL.url cur_urlf in
(match cur_urlf_url, target_url with
| Some u, Some target when OpamUrl.(
u.transport <> target.transport ||
u.path <> target.path ||
Expand Down Expand Up @@ -633,9 +634,10 @@ and source_pin

if not OpamClientConfig.(!r.show) then
OpamSwitchAction.write_selections st;
OpamConsole.msg "%s is now %s\n"
(OpamPackage.Name.to_string name)
(string_of_pinned opam);
if not (OpamStd.Option.equal OpamUrl.equal cur_urlf_url target_url) then
OpamConsole.msg "%s is now %s\n"
(OpamPackage.Name.to_string name)
(string_of_pinned opam);

st

Expand Down
2 changes: 0 additions & 2 deletions tests/reftests/autopin.test
Original file line number Diff line number Diff line change
Expand Up @@ -259,11 +259,9 @@ Done.
### opam pin -n ./foo
This will pin the following packages: foo-core, foo-format-bis, foo-format. Continue? [Y/n] y
[NOTE] Package foo-core is already pinned to file://${BASEDIR}/foo (version 2.0).
foo-core is now pinned to file://${BASEDIR}/foo (version 2.0)
[NOTE] Package foo-format-bis does not exist in opam repositories registered in the current switch.
foo-format-bis is now pinned to file://${BASEDIR}/foo (version 2.0)
[NOTE] Package foo-format is already pinned to file://${BASEDIR}/foo (version 2.0).
foo-format is now pinned to file://${BASEDIR}/foo (version 2.0)
### opam install ./foo --deps-only --show

The following system packages will first need to be installed:
Expand Down
3 changes: 0 additions & 3 deletions tests/reftests/lock.test
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,6 @@ The following actions would be performed:
- install foo 1 [required by tolock]
- install tolock 1 (pinned)
### opam install ./tolock --locked
tolock is now pinned to git+file://${BASEDIR}/tolock#master (version 1)
[NOTE] Ignoring uncommitted changes in ${BASEDIR}/tolock (`--working-dir' not specified or specified with no argument).
[tolock.1] synchronised (no changes)
The following actions will be performed:
Expand Down Expand Up @@ -630,7 +629,6 @@ The following actions would be performed:
- install foo 1 [required by tolock]
- install tolock 1 (pinned)
### opam install ./tolock --locked
tolock is now pinned to git+file://${BASEDIR}/tolock#master (version 1)
[NOTE] Ignoring uncommitted changes in ${BASEDIR}/tolock (`--working-dir' not specified or specified with no argument).
[tolock.1] synchronised (no changes)
The following actions will be performed:
Expand Down Expand Up @@ -690,7 +688,6 @@ The following actions would be performed:
- install foo 1 [required by tolock]
- install tolock 1 (pinned)
### 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 4 packages
Expand Down
10 changes: 0 additions & 10 deletions tests/reftests/pin.test
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,6 @@ Fatal error: Invalid character '/' in package version "./nip2"
# Return code 5 #
### : none - virtual
### opam pin add no-url 1 --kind none
no-url is now pinned locally (version 1)

The following actions will be performed:
=== install 1 package
Expand All @@ -312,7 +311,6 @@ The following actions will be performed:
[NOTE] Pinning command successful, but your installed packages may be out of sync.
# Return code 31 #
### opam pin add no-url2 1 --kind none
no-url2 is now pinned locally (version 1)

The following actions will be performed:
=== install 1 package
Expand Down Expand Up @@ -755,7 +753,6 @@ Done.
### sh add-pin.sh nip-mixed.dev3
### opam pin nip-mixed
[NOTE] Package nip-mixed is already pinned to file://${BASEDIR}/nip-mixed (version dev2).
nip-mixed is now pinned to file://${BASEDIR}/nip-mixed (version dev3)

The following actions will be performed:
=== upgrade 1 package
Expand Down Expand Up @@ -785,7 +782,6 @@ Done.
"add nip-mixed.dev4 package"
### opam pin nip-mixed
[NOTE] Package nip-mixed is already pinned to git+file://${BASEDIR}/nip-mixed#master (version dev4).
nip-mixed is now pinned to git+file://${BASEDIR}/nip-mixed#master (version dev1)

The following actions will be performed:
=== downgrade 1 package
Expand Down Expand Up @@ -819,7 +815,6 @@ Done.
dev1
### sh add-pin.sh nip-of.dev2 git
### opam install ./nip-of
nip-of is now pinned to git+file://${BASEDIR}/nip-of#master (version dev2)
[nip-of.dev2] synchronised (git+file://${BASEDIR}/nip-of#master)
The following actions will be performed:
=== upgrade 1 package
Expand All @@ -836,7 +831,6 @@ dev2
### git -C ./nip-of commit -qm "add install file"
### opam pin ./nip-of
[NOTE] Package nip-of is already pinned to git+file://${BASEDIR}/nip-of#master (version dev2).
nip-of is now pinned to git+file://${BASEDIR}/nip-of#master (version dev3)

The following actions will be performed:
=== upgrade 1 package
Expand Down Expand Up @@ -868,7 +862,6 @@ Done.
dev1
### sh add-pin.sh nip-fo.dev2 git
### opam install ./nip-fo
nip-fo is now pinned to git+file://${BASEDIR}/nip-fo#master (version dev2)
[nip-fo.dev2] synchronised (git+file://${BASEDIR}/nip-fo#master)
The following actions will be performed:
=== upgrade 1 package
Expand All @@ -884,7 +877,6 @@ dev2
### git -C ./nip-fo add nip-fo.dev3.t
### git -C ./nip-fo commit -qm "add install file"
### opam install ./nip-fo
nip-fo is now pinned to git+file://${BASEDIR}/nip-fo#master (version dev3)
[NOTE] Ignoring uncommitted changes in ${BASEDIR}/nip-fo (`--working-dir' not specified or specified with no argument).
[nip-fo.dev3] synchronised (git+file://${BASEDIR}/nip-fo#master)
The following actions will be performed:
Expand Down Expand Up @@ -1017,7 +1009,6 @@ The following additional pinnings are required by dep1.dev:
Pin and install them? [Y/n] y
[dep2.2] synchronised (no changes)
dep2 is now pinned to file://${BASEDIR}/dep2 (version 2)
dep1 is now pinned to file://${BASEDIR}/dep1 (version dev)

The following actions will be performed:
=== recompile 1 package
Expand Down Expand Up @@ -1077,7 +1068,6 @@ 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)
The following actions will be performed:
Expand Down
1 change: 0 additions & 1 deletion tests/reftests/upgrade.test
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,6 @@ This will pin the following packages: quuux, quux. Continue? [Y/n] y
[NOTE] Package quuux does not exist in opam repositories registered in the current switch.
quuux is now pinned to file://${BASEDIR}/quux (version dev)
[NOTE] Package quux is already pinned to file://${BASEDIR}/quux (version dev5).
quux is now pinned to file://${BASEDIR}/quux (version dev6)
### opam upgrade ./quux --installed

<><> Synchronising pinned packages ><><><><><><><><><><><><><><><><><><><><><><>
Expand Down

0 comments on commit ffc0d4f

Please sign in to comment.