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 cd0860fe625..5922dd45ae6 100644 --- a/tests/reftests/switch-list-available.test +++ b/tests/reftests/switch-list-available.test @@ -99,16 +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 +# Name # Version # Synopsis +comp-b 1 +comp-b 2 ### opam-version: "2.0" flags: compiler