Skip to content

Commit

Permalink
Merge pull request #6116 from kit-ty-kate/report-repositories-no-switch
Browse files Browse the repository at this point in the history
Always list all the repositories in 'opam config report' regardless of whether or not a switch is currently set
  • Loading branch information
rjbou authored Jul 25, 2024
2 parents 3853bfc + 752fdec commit 3e27304
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 30 deletions.
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

0 comments on commit 3e27304

Please sign in to comment.