Skip to content

Commit f5b80ec

Browse files
committed
pin: only display a "is now pinned to" message if the package is not already pinned
1 parent 46346a6 commit f5b80ec

File tree

5 files changed

+6
-20
lines changed

5 files changed

+6
-20
lines changed

src/client/opamPinCommand.ml

+6-4
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,8 @@ and source_pin
496496
registered in the current switch."
497497
(OpamPackage.Name.to_string name);
498498

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

634635
if not OpamClientConfig.(!r.show) then
635636
OpamSwitchAction.write_selections st;
636-
OpamConsole.msg "%s is now %s\n"
637-
(OpamPackage.Name.to_string name)
638-
(string_of_pinned opam);
637+
if not (OpamStd.Option.equal OpamUrl.equal cur_urlf_url target_url) then
638+
OpamConsole.msg "%s is now %s\n"
639+
(OpamPackage.Name.to_string name)
640+
(string_of_pinned opam);
639641

640642
st
641643

tests/reftests/autopin.test

-2
Original file line numberDiff line numberDiff line change
@@ -259,11 +259,9 @@ Done.
259259
### opam pin -n ./foo
260260
This will pin the following packages: foo-core, foo-format-bis, foo-format. Continue? [Y/n] y
261261
[NOTE] Package foo-core is already pinned to file://${BASEDIR}/foo (version 2.0).
262-
foo-core is now pinned to file://${BASEDIR}/foo (version 2.0)
263262
[NOTE] Package foo-format-bis does not exist in opam repositories registered in the current switch.
264263
foo-format-bis is now pinned to file://${BASEDIR}/foo (version 2.0)
265264
[NOTE] Package foo-format is already pinned to file://${BASEDIR}/foo (version 2.0).
266-
foo-format is now pinned to file://${BASEDIR}/foo (version 2.0)
267265
### opam install ./foo --deps-only --show
268266

269267
The following system packages will first need to be installed:

tests/reftests/lock.test

-3
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,6 @@ The following actions would be performed:
570570
- install foo 1 [required by tolock]
571571
- install tolock 1 (pinned)
572572
### opam install ./tolock --locked
573-
tolock is now pinned to git+file://${BASEDIR}/tolock#master (version 1)
574573
[NOTE] Ignoring uncommitted changes in ${BASEDIR}/tolock (`--working-dir' not specified or specified with no argument).
575574
[tolock.1] synchronised (no changes)
576575
The following actions will be performed:
@@ -630,7 +629,6 @@ The following actions would be performed:
630629
- install foo 1 [required by tolock]
631630
- install tolock 1 (pinned)
632631
### opam install ./tolock --locked
633-
tolock is now pinned to git+file://${BASEDIR}/tolock#master (version 1)
634632
[NOTE] Ignoring uncommitted changes in ${BASEDIR}/tolock (`--working-dir' not specified or specified with no argument).
635633
[tolock.1] synchronised (no changes)
636634
The following actions will be performed:
@@ -690,7 +688,6 @@ The following actions would be performed:
690688
- install foo 1 [required by tolock]
691689
- install tolock 1 (pinned)
692690
### opam install ./tolock --locked
693-
tolock is now pinned to git+file://${BASEDIR}/tolock#master (version 1)
694691
[tolock.1] synchronised (no changes)
695692
The following actions will be performed:
696693
=== install 4 packages

tests/reftests/pin.test

-10
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,6 @@ Fatal error: Invalid character '/' in package version "./nip2"
292292
# Return code 5 #
293293
### : none - virtual
294294
### opam pin add no-url 1 --kind none
295-
no-url is now pinned locally (version 1)
296295

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

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

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

790786
The following actions will be performed:
791787
=== downgrade 1 package
@@ -819,7 +815,6 @@ Done.
819815
dev1
820816
### sh add-pin.sh nip-of.dev2 git
821817
### opam install ./nip-of
822-
nip-of is now pinned to git+file://${BASEDIR}/nip-of#master (version dev2)
823818
[nip-of.dev2] synchronised (git+file://${BASEDIR}/nip-of#master)
824819
The following actions will be performed:
825820
=== upgrade 1 package
@@ -836,7 +831,6 @@ dev2
836831
### git -C ./nip-of commit -qm "add install file"
837832
### opam pin ./nip-of
838833
[NOTE] Package nip-of is already pinned to git+file://${BASEDIR}/nip-of#master (version dev2).
839-
nip-of is now pinned to git+file://${BASEDIR}/nip-of#master (version dev3)
840834

841835
The following actions will be performed:
842836
=== upgrade 1 package
@@ -868,7 +862,6 @@ Done.
868862
dev1
869863
### sh add-pin.sh nip-fo.dev2 git
870864
### opam install ./nip-fo
871-
nip-fo is now pinned to git+file://${BASEDIR}/nip-fo#master (version dev2)
872865
[nip-fo.dev2] synchronised (git+file://${BASEDIR}/nip-fo#master)
873866
The following actions will be performed:
874867
=== upgrade 1 package
@@ -884,7 +877,6 @@ dev2
884877
### git -C ./nip-fo add nip-fo.dev3.t
885878
### git -C ./nip-fo commit -qm "add install file"
886879
### opam install ./nip-fo
887-
nip-fo is now pinned to git+file://${BASEDIR}/nip-fo#master (version dev3)
888880
[NOTE] Ignoring uncommitted changes in ${BASEDIR}/nip-fo (`--working-dir' not specified or specified with no argument).
889881
[nip-fo.dev3] synchronised (git+file://${BASEDIR}/nip-fo#master)
890882
The following actions will be performed:
@@ -1017,7 +1009,6 @@ The following additional pinnings are required by dep1.dev:
10171009
Pin and install them? [Y/n] y
10181010
[dep2.2] synchronised (no changes)
10191011
dep2 is now pinned to file://${BASEDIR}/dep2 (version 2)
1020-
dep1 is now pinned to file://${BASEDIR}/dep1 (version dev)
10211012

10221013
The following actions will be performed:
10231014
=== recompile 1 package
@@ -1110,7 +1101,6 @@ opam-version: "2.0"
11101101
depends: "dependency" {= "1"}
11111102
### ::: behaviour when the package is not pinned
11121103
### opam install ./pin-change
1113-
pin-change is now pinned to git+file://${BASEDIR}/pin-change#master (version dev)
11141104
[NOTE] Ignoring uncommitted changes in ${BASEDIR}/pin-change (`--working-dir' not specified or specified with no argument).
11151105
[pin-change.dev] synchronised (no changes)
11161106
The following actions will be performed:

tests/reftests/upgrade.test

-1
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,6 @@ This will pin the following packages: quuux, quux. Continue? [Y/n] y
308308
[NOTE] Package quuux does not exist in opam repositories registered in the current switch.
309309
quuux is now pinned to file://${BASEDIR}/quux (version dev)
310310
[NOTE] Package quux is already pinned to file://${BASEDIR}/quux (version dev5).
311-
quux is now pinned to file://${BASEDIR}/quux (version dev6)
312311
### opam upgrade ./quux --installed
313312

314313
<><> Synchronising pinned packages ><><><><><><><><><><><><><><><><><><><><><><>

0 commit comments

Comments
 (0)