Skip to content

Commit

Permalink
Always list all the repositories in 'opam config report' regardless o…
Browse files Browse the repository at this point in the history
…f whether or not a switch is currently set
  • Loading branch information
kit-ty-kate committed Jul 24, 2024
1 parent 1c85401 commit 62d9c75
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 30 deletions.
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 62d9c75

Please sign in to comment.