Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't ask confirmation when pinning a new package #6309

Merged
merged 1 commit into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions master_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ users)
## Pin
* [NEW] Make it so pin list display the current revision of a pinned repository in a new column [#6274 @desumn - fix #5533]
* [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]

## List

Expand Down
10 changes: 4 additions & 6 deletions src/client/opamPinCommand.ml
Original file line number Diff line number Diff line change
Expand Up @@ -491,12 +491,10 @@ and source_pin
version, None
in

if not (OpamPackage.has_name st.packages name) &&
not (OpamConsole.confirm
"Package %s does not exist, create as a %s package?"
(OpamPackage.Name.to_string name)
(OpamConsole.colorise `bold "NEW"))
then raise Aborted;
if not (OpamPackage.has_name st.packages name) then
OpamConsole.note "Package %s does not exist in opam repositories \
registered in the current switch."
(OpamPackage.Name.to_string name);

(match OpamStd.Option.map OpamFile.URL.url cur_urlf, target_url with
| Some u, Some target when OpamUrl.(
Expand Down
6 changes: 3 additions & 3 deletions tests/reftests/assume-built.test
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ versionned
new!
### opam switch create assume-built --empty
### opam pin ./ongoing -n
Package ongoing does not exist, create as a NEW package? [Y/n] y
[NOTE] Package ongoing does not exist in opam repositories registered in the current switch.
ongoing is now pinned to git+file://${BASEDIR}/ongoing#master (version dev)
### : assume built
### opam install ongoing -v | sed-cmd test | sed-cmd sh | sed-cmd touch
Expand Down Expand Up @@ -199,7 +199,7 @@ install: [
]
### git -C ongoing clean -fdqx
### opam pin ./ongoing -n
Package ongoing does not exist, create as a NEW package? [Y/n] y
[NOTE] Package ongoing does not exist in opam repositories registered in the current switch.
ongoing is now pinned to git+file://${BASEDIR}/ongoing#master (version 1.0)
### touch ongoing/out
### opam install qux
Expand Down Expand Up @@ -253,7 +253,7 @@ install: [
]
### git -C ongoing clean -fdqx
### opam pin ./ongoing -n
Package ongoing does not exist, create as a NEW package? [Y/n] y
[NOTE] Package ongoing does not exist in opam repositories registered in the current switch.
ongoing is now pinned to git+file://${BASEDIR}/ongoing#master (version dev)
### touch ongoing/out
### opam install ongoing --assume-built --with-test
Expand Down
2 changes: 1 addition & 1 deletion tests/reftests/autopin.test
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ Done.
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)
Package foo-format-bis does not exist, create as a NEW package? [Y/n] y
[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)
Expand Down
2 changes: 1 addition & 1 deletion tests/reftests/config.test
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ opam-version: "2.0"
### opam repository add second ./REPO2 --this-switch
[second] Initialised
### opam pin pinned-package -y
Package pinned-package does not exist, create as a NEW package? [Y/n] y
[NOTE] Package pinned-package does not exist in opam repositories registered in the current switch.
pinned-package is now pinned to file://${BASEDIR}/pinned-package (version dev)

The following actions will be performed:
Expand Down
8 changes: 4 additions & 4 deletions tests/reftests/conflict-resto.test
Original file line number Diff line number Diff line change
Expand Up @@ -390,10 +390,10 @@ Faking installation of ocaml-options-vanilla.1
Done.
### OPAMVAR_os=linux opam pin resto/ --with-version=0.6.1 --show --yes | unordered
This will pin the following packages: ezresto-directory, ezresto, resto-acl, resto-client, resto-cohttp-client, resto-cohttp-self-serving-client, resto-cohttp-server, resto-cohttp, resto-directory, resto-json, resto-lwt, resto-self-serving-client, resto-server, resto. Continue? [Y/n] y
Package resto-client does not exist, create as a NEW package? [Y/n] y
Package resto-lwt does not exist, create as a NEW package? [Y/n] y
Package resto-self-serving-client does not exist, create as a NEW package? [Y/n] y
Package resto-server does not exist, create as a NEW package? [Y/n] y
[NOTE] Package resto-client does not exist in opam repositories registered in the current switch.
[NOTE] Package resto-lwt does not exist in opam repositories registered in the current switch.
[NOTE] Package resto-self-serving-client does not exist in opam repositories registered in the current switch.
[NOTE] Package resto-server does not exist in opam repositories registered in the current switch.
ezresto-directory is now pinned to file://${BASEDIR}/resto (version 0.6.1)
ezresto is now pinned to file://${BASEDIR}/resto (version 0.6.1)
resto-acl is now pinned to file://${BASEDIR}/resto (version 0.6.1)
Expand Down
4 changes: 2 additions & 2 deletions tests/reftests/fetch-package.test
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ root.ml
### :: pinning
### opam switch create downloads-pin --empty
### opam pin foo-arch-pin arch.tgz -y
Package foo-arch-pin does not exist, create as a NEW package? [Y/n] y
[NOTE] Package foo-arch-pin does not exist in opam repositories registered in the current switch.
[foo-arch-pin.dev] synchronised (file://${BASEDIR}/arch.tgz)
foo-arch-pin is now pinned to file://${BASEDIR}/arch.tgz (version dev)

Expand All @@ -108,7 +108,7 @@ files
opam
root.ml
### opam pin foo-git-pin ./a-dev -y
Package foo-git-pin does not exist, create as a NEW package? [Y/n] y
[NOTE] Package foo-git-pin does not exist in opam repositories registered in the current switch.
[foo-git-pin.dev] synchronised (git+file://${BASEDIR}/a-dev#master)
foo-git-pin is now pinned to git+file://${BASEDIR}/a-dev#master (version dev)

Expand Down
2 changes: 1 addition & 1 deletion tests/reftests/inplace.test
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ versionned
new!
### opam switch create inplace --empty
### opam pin ./ongoing -n
Package ongoing does not exist, create as a NEW package? [Y/n] y
[NOTE] Package ongoing does not exist in opam repositories registered in the current switch.
ongoing is now pinned to git+file://${BASEDIR}/ongoing#master (version dev)
### opam install ongoing -v | sed-cmd test | sed-cmd cat | sed-cmd touch

Expand Down
4 changes: 2 additions & 2 deletions tests/reftests/json.unix.test
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ The former state can be restored with:
### <pin:nip/nip.opam>
opam-version:"2.0"
### opam pin ./nip --json=out.json
Package nip does not exist, create as a NEW package? [Y/n] y
[NOTE] Package nip does not exist in opam repositories registered in the current switch.
nip is now pinned to file://${BASEDIR}/nip (version dev)

The following actions will be performed:
Expand Down Expand Up @@ -665,7 +665,7 @@ Done.
]
}
### opam install ./nip --json=out.json
Package nip does not exist, create as a NEW package? [Y/n] y
[NOTE] Package nip does not exist in opam repositories registered in the current switch.
nip is now pinned to file://${BASEDIR}/nip (version dev)
The following actions will be performed:
=== install 1 package
Expand Down
2 changes: 1 addition & 1 deletion tests/reftests/list-large-dependencies.test
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ phylogenetics.0.0.0
available: !?force-unav
flags: compiler
### opam switch create ${BASEDIR}/test-not-in-repo --yes
Package test-not-in-repo does not exist, create as a NEW package? [Y/n] y
[NOTE] Package test-not-in-repo does not exist in opam repositories registered in the current switch.
test-not-in-repo is now pinned to file://${BASEDIR}/test-not-in-repo (version dev)

<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><>
Expand Down
38 changes: 19 additions & 19 deletions tests/reftests/lock.test
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ it's here
### : simple lock file :
### opam switch create locking --empty
### opam pin -n ./tolock --with-version 1
Package tolock does not exist, create as a NEW package? [Y/n] y
[NOTE] Package tolock does not exist in opam repositories registered in the current switch.
tolock is now pinned to file://${BASEDIR}/tolock (version 1)
### opam lock tolock
[ERROR] Skipping tolock.1, dependencies are not satisfied in this switch, not installed packages are:
Expand Down Expand Up @@ -141,7 +141,7 @@ opam-version: "2.0"
synopsis: "A word"
version: "1"
### opam pin -n ./tolock --locked
Package tolock does not exist, create as a NEW package? [Y/n] y
[NOTE] Package tolock does not exist in opam repositories registered in the current switch.
tolock is now pinned to file://${BASEDIR}/tolock (version 1)
### opam show --normalise tolock --field depends:,depopts:,conflicts:
depends: ["bar" {= "1"} "baz" {= "1"} "foo" {= "1"}]
Expand Down Expand Up @@ -177,7 +177,7 @@ The following actions would be performed:
- install foo 1 [required by tolock]
- install tolock 1 (pinned)
### opam install ./tolock/tolock.opam --locked
Package tolock does not exist, create as a NEW package? [Y/n] y
[NOTE] Package tolock does not exist in opam repositories registered in the current switch.
tolock is now pinned to file://${BASEDIR}/tolock (version 1)
The following actions will be performed:
=== install 4 packages
Expand Down Expand Up @@ -206,7 +206,7 @@ Done.
opam-version: "2.0"
depends: "foo"
### opam pin -n old1
Package oldlock does not exist, create as a NEW package? [Y/n] y
[NOTE] Package oldlock does not exist in opam repositories registered in the current switch.
oldlock is now pinned to file://${BASEDIR}/old1 (version dev)
### opam lock oldlock
Generated lock files for:
Expand Down Expand Up @@ -266,7 +266,7 @@ Done.
opam-version: "2.0"
depends: "foo"
### opam pin -n old2
Package granpa does not exist, create as a NEW package? [Y/n] y
[NOTE] Package granpa does not exist in opam repositories registered in the current switch.
granpa is now pinned to file://${BASEDIR}/old2 (version opam)
### opam lock granpa
Generated lock files for:
Expand Down Expand Up @@ -326,7 +326,7 @@ Done.
opam-version: "2.0"
depends: "foo"
### opam pin -n old3
Package ancestor does not exist, create as a NEW package? [Y/n] y
[NOTE] Package ancestor does not exist in opam repositories registered in the current switch.
ancestor is now pinned to file://${BASEDIR}/old3 (version opam)
### opam lock ancestor
Generated lock files for:
Expand Down Expand Up @@ -387,7 +387,7 @@ opam-version: "2.0"
name: "silver"
depends: "foo"
### opam pin -n old
Package silver does not exist, create as a NEW package? [Y/n] y
[NOTE] Package silver does not exist in opam repositories registered in the current switch.
silver is now pinned to file://${BASEDIR}/old (version dev)
### opam lock silver
Generated lock files for:
Expand Down Expand Up @@ -532,7 +532,7 @@ tolock-scan locked-version file://${BASEDIR}/tolock-scan -
### git -C tolock commit -qm "init"
### opam switch create locking3 --empty
### opam pin -n ./tolock --locked
Package tolock does not exist, create as a NEW package? [Y/n] y
[NOTE] Package tolock does not exist in opam repositories registered in the current switch.
tolock is now pinned to git+file://${BASEDIR}/tolock#master (version 1)
### opam show --normalise tolock --field depends:,depopts:,conflicts:
depends: ["bar" {= "1"} "baz" {= "1"} "foo" {= "1"}]
Expand All @@ -554,7 +554,7 @@ The following actions would be performed:
- install foo 1 [required by tolock]
- install tolock 1 (pinned)
### opam pin ./tolock -n
Package tolock does not exist, create as a NEW package? [Y/n] y
[NOTE] Package tolock does not exist in opam repositories registered in the current switch.
tolock is now pinned to git+file://${BASEDIR}/tolock#master (version dev)
### opam install ./tolock --show
The following actions would be performed:
Expand Down Expand Up @@ -592,7 +592,7 @@ Done.
### git -C tolock commit -qm "opam file"
### opam switch create locking4 --empty
### opam pin -n ./tolock --locked
Package tolock does not exist, create as a NEW package? [Y/n] y
[NOTE] Package tolock does not exist in opam repositories registered in the current switch.
tolock is now pinned to git+file://${BASEDIR}/tolock#master (version 1)
### opam show --normalise tolock --field depends:,depopts:,conflicts:
depends: ["bar" {= "1"} "baz" {= "1"} "foo" {= "1"}]
Expand All @@ -614,7 +614,7 @@ The following actions would be performed:
- install foo 1 [required by tolock]
- install tolock 1 (pinned)
### opam pin ./tolock -n
Package tolock does not exist, create as a NEW package? [Y/n] y
[NOTE] Package tolock does not exist in opam repositories registered in the current switch.
tolock is now pinned to git+file://${BASEDIR}/tolock#master (version dev)
### opam install ./tolock --show
The following actions would be performed:
Expand Down Expand Up @@ -652,7 +652,7 @@ Done.
### git -C tolock commit -qm "lock"
### opam switch create locking5 --empty
### opam pin -n ./tolock --locked
Package tolock does not exist, create as a NEW package? [Y/n] y
[NOTE] Package tolock does not exist in opam repositories registered in the current switch.
tolock is now pinned to git+file://${BASEDIR}/tolock#master (version 1)
### opam show --normalise tolock --field depends:,depopts:,conflicts:
depends: ["bar" {= "1"} "baz" {= "1"} "foo" {= "1"}]
Expand All @@ -674,7 +674,7 @@ The following actions would be performed:
- install foo 1 [required by tolock]
- install tolock 1 (pinned)
### opam pin ./tolock -n
Package tolock does not exist, create as a NEW package? [Y/n] y
[NOTE] Package tolock does not exist in opam repositories registered in the current switch.
tolock is now pinned to git+file://${BASEDIR}/tolock#master (version dev)
### opam install ./tolock --show
The following actions would be performed:
Expand Down Expand Up @@ -716,7 +716,7 @@ The following actions will be performed:
-> removed tolock.1
Done.
### opam install ./tolock --locked
Package tolock does not exist, create as a NEW package? [Y/n] y
[NOTE] Package tolock does not exist in opam repositories registered in the current switch.
tolock is now pinned to git+file://${BASEDIR}/tolock#master (version 1)
The following actions will be performed:
=== install 1 package
Expand Down Expand Up @@ -754,7 +754,7 @@ version: "1"
### <pin:tolock/tolock.opam.locked>
version: "l1"
### opam pin ./tolock --locked
Package tolock does not exist, create as a NEW package? [Y/n] y
[NOTE] Package tolock does not exist in opam repositories registered in the current switch.
tolock is now pinned to file://${BASEDIR}/tolock (version l1)

The following actions will be performed:
Expand Down Expand Up @@ -1104,22 +1104,22 @@ pin-depends: [
### OPAMYES=1
### OPAMLOCKED=locked
### opam pin add -n goblint.dev ./goblint
Package goblint does not exist, create as a NEW package? [Y/n] y
[NOTE] Package goblint does not exist in opam repositories registered in the current switch.
[goblint.dev] synchronised (file://${BASEDIR}/goblint)
The following additional pinnings are required by goblint.dev:
- apron.v0.9.13 at git+https://github.com/antoinemine/apron.git#c852ebcc89e5cf4a5a3318e7c13c73e1756abb11
- goblint-cil.1.8.2 at git+https://github.com/goblint/cil.git#a3c91aa6e8f946fec9a9a13361b051a73b12a65c
- ppx_deriving.5.2.1 at git+https://github.com/ocaml-ppx/ppx_deriving.git#0a89b619f94cbbfc3b0fb3255ab4fe5bc77d32d6
Pin and install them? [Y/n] y
Package apron does not exist, create as a NEW package? [Y/n] y
[NOTE] Package apron does not exist in opam repositories registered in the current switch.
[apron.v0.9.13] synchronised (no changes)
[WARNING] Failed checks on apron package definition from source at git+https://github.com/antoinemine/apron.git#c852ebcc89e5cf4a5a3318e7c13c73e1756abb11:
warning 62: License doesn't adhere to the SPDX standard, see https://spdx.org/licenses/ : "LGPL-2.1 with linking exception"
apron is now pinned to git+https://github.com/antoinemine/apron.git#c852ebcc89e5cf4a5a3318e7c13c73e1756abb11 (version v0.9.13)
Package goblint-cil does not exist, create as a NEW package? [Y/n] y
[NOTE] Package goblint-cil does not exist in opam repositories registered in the current switch.
[goblint-cil.1.8.2] synchronised (no changes)
goblint-cil is now pinned to git+https://github.com/goblint/cil.git#a3c91aa6e8f946fec9a9a13361b051a73b12a65c (version 1.8.2)
Package ppx_deriving does not exist, create as a NEW package? [Y/n] y
[NOTE] Package ppx_deriving does not exist in opam repositories registered in the current switch.
[ppx_deriving.5.2.1] synchronised (no changes)
ppx_deriving is now pinned to git+https://github.com/ocaml-ppx/ppx_deriving.git#0a89b619f94cbbfc3b0fb3255ab4fe5bc77d32d6 (version 5.2.1)
goblint is now pinned to file://${BASEDIR}/goblint (version dev)
Expand Down
12 changes: 6 additions & 6 deletions tests/reftests/pin-legacy.test
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ foo is now pinned locally (version 1)
### <pin:nip/nip.opam>
opam-version: "2.0"
### opam install ./nip
Package nip does not exist, create as a NEW package? [Y/n] y
[NOTE] Package nip does not exist in opam repositories registered in the current switch.
nip is now pinned to file://${BASEDIR}/nip (version dev)
The following actions will be performed:
=== install 1 package
Expand Down Expand Up @@ -96,11 +96,11 @@ echo "pin-depends: [ \"qux.dev\" \"file://$basedir/qux\" ]" >> bar/bar.opam
opam-version: "2.0"
depexts: [ "another-inexistant" ]
### opam pin ./bar | '.*(/|\\|")echo(\.exe)?"? "' -> 'echo "'
Package bar does not exist, create as a NEW package? [Y/n] y
[NOTE] Package bar does not exist in opam repositories registered in the current switch.
The following additional pinnings are required by bar.dev:
- qux.dev at file://${BASEDIR}/qux
Pin and install them? [Y/n] y
Package qux does not exist, create as a NEW package? [Y/n] y
[NOTE] Package qux does not exist in opam repositories registered in the current switch.
[qux.dev] synchronised (no changes)
qux is now pinned to file://${BASEDIR}/qux (version dev)
bar is now pinned to file://${BASEDIR}/bar (version dev)
Expand Down Expand Up @@ -146,11 +146,11 @@ The following actions will be performed:
-> removed qux.dev
Done.
### opam install ./bar | '.*(/|\\|")echo(\.exe)?"? "' -> 'echo "'
Package bar does not exist, create as a NEW package? [Y/n] y
[NOTE] Package bar does not exist in opam repositories registered in the current switch.
The following additional pinnings are required by bar.dev:
- qux.dev at file://${BASEDIR}/qux
Pin and install them? [Y/n] y
Package qux does not exist, create as a NEW package? [Y/n] y
[NOTE] Package qux does not exist in opam repositories registered in the current switch.
[qux.dev] synchronised (no changes)
qux is now pinned to file://${BASEDIR}/qux (version dev)
bar is now pinned to file://${BASEDIR}/bar (version dev)
Expand Down Expand Up @@ -265,7 +265,7 @@ Continue anyway? [Y/n] y
### git -C pin-empty add -A
### git -C pin-empty commit -qm 'opam'
### opam pin --no-action ./pin-empty
Package pin-empty does not exist, create as a NEW package? [Y/n] y
[NOTE] Package pin-empty does not exist in opam repositories registered in the current switch.
pin-empty is now pinned to git+file://${BASEDIR}/pin-empty#master (version dev)
### opam unpin pin-empty
Ok, pin-empty is no longer pinned to git+file://${BASEDIR}/pin-empty#master (version dev)
Expand Down
Loading