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 rjbou committed Oct 30, 2024
1 parent 0297f90 commit 4a5dc46
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
1 change: 1 addition & 0 deletions master_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ users)
* [BUG] Ensure the output of opam commands using a column style UI stay consistent accross environment by setting the number of columns to 80 if stdout is not a tty and if the `COLUMNS` env variable is not set [#6244 @kit-ty-kate]

## Switch
* [BUG] Correctly handle `pkg.version` pattern in `opam switch list-available` [#6186 @arozovyk - fix #6152]

## Config

Expand Down
10 changes: 2 additions & 8 deletions src/client/opamCommands.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2894,16 +2894,10 @@ let switch cli =
(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
OpamListCommand.pattern_selector ~concat:OpamFormula.ands pattlist
in
let all_compilers =
OpamListCommand.filter ~base:compilers st
(OpamFormula.ands (List.map (fun f -> OpamFormula.Atom f) filters))
OpamListCommand.filter ~base:compilers st filters
in
let compilers =
if all then
Expand Down
10 changes: 7 additions & 3 deletions tests/reftests/switch-list-available.test
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,20 @@ 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
### <pkg:comp_c.1>
opam-version: "2.0"
flags: compiler
Expand Down

0 comments on commit 4a5dc46

Please sign in to comment.