Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix opam switch list-available pkg.version pattern #6186

Merged
merged 2 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading