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 a6f191c commit e45202e
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 @@ -39,6 +39,7 @@ users)

## Switch
* [BUG] Fix `opam switch remove <dir>` failure when it is a linked switch [#6276 @btjorge - fix #6275]
* [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 @@ -2895,16 +2895,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 e45202e

Please sign in to comment.