From b6b0aa6accbd3abbcbe8dbca00849f6dfc690c70 Mon Sep 17 00:00:00 2001 From: Raja Boujbel Date: Wed, 15 Jan 2025 14:55:22 +0100 Subject: [PATCH 1/3] reftest: add double pinning with opam/pam test --- master_changes.md | 1 + tests/reftests/pin.test | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/master_changes.md b/master_changes.md index fe42c861507..e7ece6994e7 100644 --- a/master_changes.md +++ b/master_changes.md @@ -154,6 +154,7 @@ users) * Add switch removal test: failure on removal linked switch [#6276 @btjorge] * Extend the tests on opam admin to include packages using builtin global variables [#6331 @kit-ty-kate] * Extend the tests on opam admin check by including all the arguments [#6331 @kit-ty-kate @rjbou] + * Add double pinning test in case of opam/opam opam file [#6343 @rjbou] ### Engine diff --git a/tests/reftests/pin.test b/tests/reftests/pin.test index 0f70077adb5..5362b012c23 100644 --- a/tests/reftests/pin.test +++ b/tests/reftests/pin.test @@ -937,3 +937,13 @@ vcs-local is now pinned to git+file://${BASEDIR}/vcs-local#master (version dev) ### opam show vcs-local --field build:,url.src: build: "false" url.src: "git+file://${BASEDIR}/vcs-local#master" +### :C:b: double pinning when the opam file is opam/opam +### +opam-version: "2.0" +name: "double" +### opam pin -n double +This will pin the following packages: double, double. Continue? [Y/n] y +Package double does not exist, create as a NEW package? [Y/n] y +double is now pinned to file://${BASEDIR}/double (version dev) +[NOTE] Package double is already pinned to file://${BASEDIR}/double (version dev). +double is now pinned to file://${BASEDIR}/double (version dev) From 9e3bd2fb1fcb07c98eed71cf809dbf95b8b38f30 Mon Sep 17 00:00:00 2001 From: Kate Date: Thu, 19 Dec 2024 22:55:08 +0000 Subject: [PATCH 2/3] Stop double pin of packages located in ./opam/opam --- master_changes.md | 1 + src/state/opamPinned.ml | 5 ++--- tests/reftests/lock.test | 5 +---- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/master_changes.md b/master_changes.md index e7ece6994e7..e68d2f848b7 100644 --- a/master_changes.md +++ b/master_changes.md @@ -46,6 +46,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] ## List diff --git a/src/state/opamPinned.ml b/src/state/opamPinned.ml index fac5d8ecd83..c92f3e5aa31 100644 --- a/src/state/opamPinned.ml +++ b/src/state/opamPinned.ml @@ -193,9 +193,8 @@ let files_in_source ?locked ?(recurse=false) ?subpath d = in List.fold_left (fun acc d -> - if OpamFilename.(basename_dir d = Base.of_string "opam") || - OpamStd.String.ends_with ~suffix:".opam" - (OpamFilename.Dir.to_string d) + if OpamStd.String.ends_with ~suffix:".opam" + (OpamFilename.Dir.to_string d) then match OpamFilename.opt_file OpamFilename.Op.(d//"opam") with | None -> acc diff --git a/tests/reftests/lock.test b/tests/reftests/lock.test index ea2910f2432..e8ff5903f86 100644 --- a/tests/reftests/lock.test +++ b/tests/reftests/lock.test @@ -386,13 +386,10 @@ Done. opam-version: "2.0" name: "silver" depends: "foo" -### # ERROR double silver +### : Make sure silver isn't pinned twice ### opam pin -n old -This will pin the following packages: silver, silver. Continue? [Y/n] y Package silver does not exist, create as a NEW package? [Y/n] y silver is now pinned to file://${BASEDIR}/old (version dev) -[NOTE] Package silver is already pinned to file://${BASEDIR}/old (version dev). -silver is now pinned to file://${BASEDIR}/old (version dev) ### opam lock silver Generated lock files for: - silver.dev: ${BASEDIR}/silver.opam.locked From f926ed6d6b41f5b0f2f23ee97028d31503e72f17 Mon Sep 17 00:00:00 2001 From: Raja Boujbel Date: Wed, 15 Jan 2025 14:55:53 +0100 Subject: [PATCH 3/3] fixup! Stop double pin of packages located in ./opam/opam --- tests/reftests/lock.test | 1 - tests/reftests/pin.test | 3 --- 2 files changed, 4 deletions(-) diff --git a/tests/reftests/lock.test b/tests/reftests/lock.test index e8ff5903f86..37243ebdd5b 100644 --- a/tests/reftests/lock.test +++ b/tests/reftests/lock.test @@ -386,7 +386,6 @@ Done. opam-version: "2.0" name: "silver" depends: "foo" -### : Make sure silver isn't pinned twice ### opam pin -n old Package silver does not exist, create as a NEW package? [Y/n] y silver is now pinned to file://${BASEDIR}/old (version dev) diff --git a/tests/reftests/pin.test b/tests/reftests/pin.test index 5362b012c23..5a6b83269ab 100644 --- a/tests/reftests/pin.test +++ b/tests/reftests/pin.test @@ -942,8 +942,5 @@ url.src: "git+file://${BASEDIR}/vcs-local#master" opam-version: "2.0" name: "double" ### opam pin -n double -This will pin the following packages: double, double. Continue? [Y/n] y Package double does not exist, create as a NEW package? [Y/n] y double is now pinned to file://${BASEDIR}/double (version dev) -[NOTE] Package double is already pinned to file://${BASEDIR}/double (version dev). -double is now pinned to file://${BASEDIR}/double (version dev)