Skip to content

Commit

Permalink
switch: Correctly handle pkg.version pattern with 'list-available'
Browse files Browse the repository at this point in the history
  • Loading branch information
arozovyk authored and kit-ty-kate committed Nov 30, 2024
1 parent 7f19d54 commit 06b9efd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
1 change: 1 addition & 0 deletions master_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ users)
## Switch
* [BUG] Fix `opam switch remove <dir>` failure when it is a linked switch [#6276 @btjorge - fix #6275]
* 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

Expand Down
14 changes: 2 additions & 12 deletions src/client/opamCommands.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 10 additions & 4 deletions tests/reftests/switch-list-available.test
Original file line number Diff line number Diff line change
Expand Up @@ -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
### <pkg:comp_c.1>
opam-version: "2.0"
flags: compiler
Expand Down

0 comments on commit 06b9efd

Please sign in to comment.