Skip to content

Commit

Permalink
Merge pull request #6186 from arozovyk/list_available_pkg.version_pat
Browse files Browse the repository at this point in the history
Fix `opam switch list-available pkg.version` pattern
  • Loading branch information
kit-ty-kate authored Dec 3, 2024
2 parents 5fc2c29 + 69a1fc5 commit 8a38781
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 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]
* [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

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

0 comments on commit 8a38781

Please sign in to comment.