From 1f950128e0bc1380807b88d67b9a469865fb1cca Mon Sep 17 00:00:00 2001 From: Kate Date: Sat, 30 Nov 2024 23:55:00 +0000 Subject: [PATCH 1/2] Extend the tests showing the behaviour of opam switch list-available in presence of several pkg.ver arguments --- tests/reftests/switch-list-available.test | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/reftests/switch-list-available.test b/tests/reftests/switch-list-available.test index cd0860fe625..b1478a9d42f 100644 --- a/tests/reftests/switch-list-available.test +++ b/tests/reftests/switch-list-available.test @@ -109,6 +109,9 @@ comp-b 4 ### opam switch list-available comp-b.2 --all # Listing available compilers from repositories: default # No matches found +### opam switch list-available comp-b.1 comp-b.2 --all +# Listing available compilers from repositories: default +# No matches found ### opam-version: "2.0" flags: compiler From 69a1fc58e4966d67e86a1711c707a43c9912b988 Mon Sep 17 00:00:00 2001 From: arozovyk Date: Mon, 2 Sep 2024 11:52:28 +0200 Subject: [PATCH 2/2] switch: Correctly handle pkg.version pattern with 'list-available' --- master_changes.md | 1 + src/client/opamCommands.ml | 14 ++------------ tests/reftests/switch-list-available.test | 14 ++++++++++---- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/master_changes.md b/master_changes.md index fad17f3ef0e..2373c9b5fc9 100644 --- a/master_changes.md +++ b/master_changes.md @@ -40,6 +40,7 @@ users) ## Switch * [BUG] Fix `opam switch remove ` failure when it is a linked switch [#6276 @btjorge - fix #6275] * [BUG] Fix `opam switch list-available` when given several arguments [#6318 @kit-ty-kate] + * [BUG] Correctly handle `pkg.version` pattern in `opam switch list-available` [#6186 @arozovyk - fix #6152] ## Config diff --git a/src/client/opamCommands.ml b/src/client/opamCommands.ml index 83f15c3f1b4..9e2827ff733 100644 --- a/src/client/opamCommands.ml +++ b/src/client/opamCommands.ml @@ -2894,18 +2894,8 @@ let switch cli = OpamConsole.msg "# Listing available compilers from repositories: %s\n" (OpamStd.List.concat_map ", " OpamRepositoryName.to_string (OpamStd.Option.default (OpamGlobalState.repos_list gt) repos)); - let filters = - List.map (fun patt -> - OpamListCommand.Pattern - ({ OpamListCommand.default_pattern_selector with - OpamListCommand.fields = ["name"; "version"] }, - patt)) - pattlist - in - let all_compilers = - OpamListCommand.filter ~base:compilers st - (OpamFormula.ors (List.map (fun f -> OpamFormula.Atom f) filters)) - in + let filters = OpamListCommand.pattern_selector pattlist in + let all_compilers = OpamListCommand.filter ~base:compilers st filters in let compilers = if all then all_compilers diff --git a/tests/reftests/switch-list-available.test b/tests/reftests/switch-list-available.test index b1478a9d42f..5922dd45ae6 100644 --- a/tests/reftests/switch-list-available.test +++ b/tests/reftests/switch-list-available.test @@ -99,19 +99,25 @@ comp-b 3 comp-b 4 ### opam switch list-available comp-b.1 # Listing available compilers from repositories: default -# No matches found +# Name # Version # Synopsis +comp-b 1 ### opam switch list-available comp-b.1 --all # Listing available compilers from repositories: default -# No matches found +# Name # Version # Synopsis +comp-b 1 ### opam switch list-available comp-b.2 # Listing available compilers from repositories: default # No matches found +[NOTE] Some compilers have been hidden (e.g. pre-releases). If you want to display them, run: 'opam switch list-available --all' ### opam switch list-available comp-b.2 --all # Listing available compilers from repositories: default -# No matches found +# Name # Version # Synopsis +comp-b 2 ### opam switch list-available comp-b.1 comp-b.2 --all # Listing available compilers from repositories: default -# No matches found +# Name # Version # Synopsis +comp-b 1 +comp-b 2 ### opam-version: "2.0" flags: compiler