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

Always list all the repositories in 'opam config report' regardless of whether or not a switch is currently set #6116

Merged
merged 1 commit into from
Jul 25, 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 @@ -23,6 +23,7 @@ users)
* Suppress all the Windows menus when running with `opam init -ya` [#6034 @dra27]

## Config report
* Always list all the repositories regardless of whether or not a switch is currently set [#6116 @kit-ty-kate]

## Actions
* Add support for wget2 [#6104 @kit-ty-kate]
Expand Down
61 changes: 31 additions & 30 deletions src/client/opamCommands.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1487,39 +1487,40 @@ let config cli =
if n <> 0 then [Printf.sprintf "%d (%s)" n label]
else [] in
print "jobs" "%d" (Lazy.force OpamStateConfig.(!r.jobs));
OpamRepositoryState.with_ `Lock_none gt @@ fun rt ->
print "repositories" "%s"
(let repos = rt.repositories in
let default, nhttp, nlocal, nvcs =
OpamRepositoryName.Map.fold
(fun _ repo (dft, nhttp, nlocal, nvcs) ->
let dft =
if OpamUrl.root repo.repo_url =
OpamUrl.root OpamInitDefaults.repository_url
then
OpamRepositoryName.Map.find
repo.repo_name
rt.repos_definitions |>
OpamFile.Repo.stamp
else dft
in
match repo.repo_url.OpamUrl.backend with
| `http -> dft, nhttp+1, nlocal, nvcs
| `rsync -> dft, nhttp, nlocal+1, nvcs
| _ -> dft, nhttp, nlocal, nvcs+1)
repos (None,0,0,0)
in
String.concat ", "
(nprint "http" nhttp @
nprint "local" nlocal @
nprint "version-controlled" nvcs) ^
match default with
| Some v -> Printf.sprintf " (default repo at %s)" v
| None -> ""
);
match OpamStateConfig.get_switch_opt () with
| None -> print "current-switch" "%s" "none set"; `Ok ()
| Some switch ->
OpamSwitchState.with_ `Lock_none ~switch gt @@ fun state ->
print "repositories" "%s"
(let repos = state.switch_repos.repositories in
let default, nhttp, nlocal, nvcs =
OpamRepositoryName.Map.fold
(fun _ repo (dft, nhttp, nlocal, nvcs) ->
let dft =
if OpamUrl.root repo.repo_url =
OpamUrl.root OpamInitDefaults.repository_url
then
OpamRepositoryName.Map.find
repo.repo_name
state.switch_repos.repos_definitions |>
OpamFile.Repo.stamp
else dft
in
match repo.repo_url.OpamUrl.backend with
| `http -> dft, nhttp+1, nlocal, nvcs
| `rsync -> dft, nhttp, nlocal+1, nvcs
| _ -> dft, nhttp, nlocal, nvcs+1)
repos (None,0,0,0)
in
String.concat ", "
(nprint "http" nhttp @
nprint "local" nlocal @
nprint "version-controlled" nvcs) ^
match default with
| Some v -> Printf.sprintf " (default repo at %s)" v
| None -> ""
);
OpamSwitchState.with_ `Lock_none ~rt ~switch gt @@ fun state ->
print "pinned" "%s"
(if OpamPackage.Set.is_empty state.pinned then "0" else
let pinnings =
Expand Down
1 change: 1 addition & 0 deletions tests/reftests/config.test
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Set to '"-removed"' the field solver-upgrade-criteria in global configuration
# install-criteria -removed
# upgrade-criteria -removed
# jobs 1
# repositories 1 (local)
# current-switch none set
### # empty switch
### opam switch create an-empty-switch --empty
Expand Down
Loading