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

opam config report: add the list of all installed repositories #5799

Closed
Closed
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 @@ -22,6 +22,7 @@ users)
## Init

## Config report
* add the list of all installed repositories to a new all-repositories field [#5799 @kit-ty-kate]

## Actions

Expand Down
19 changes: 12 additions & 7 deletions src/client/opamCommands.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1487,12 +1487,9 @@ let config cli =
if n <> 0 then [Printf.sprintf "%d (%s)" n label]
else [] in
print "jobs" "%d" (Lazy.force OpamStateConfig.(!r.jobs));
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 print_repositories name rt =
print name "%s"
(let repos = rt.repositories in
let default, nhttp, nlocal, nvcs =
OpamRepositoryName.Map.fold
(fun _ repo (dft, nhttp, nlocal, nvcs) ->
Expand All @@ -1502,7 +1499,7 @@ let config cli =
then
OpamRepositoryName.Map.find
repo.repo_name
state.switch_repos.repos_definitions |>
rt.repos_definitions |>
OpamFile.Repo.stamp
else dft
in
Expand All @@ -1520,6 +1517,14 @@ let config cli =
| Some v -> Printf.sprintf " (default repo at %s)" v
| None -> ""
);
in
OpamRepositoryState.with_ `Lock_none gt @@ fun rt ->
print_repositories "all-repositories" rt;
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 "repositories" state.switch_repos;
Comment on lines +1522 to +1527
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the difference between all-repositories and repositories fields

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

repositories only shows the list of repositories from the current switch.
all-repositories shows all of them (as in: opam repository list -a)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... It is then the wrong value used: rt = state.switch_repos, to access to switch state repos, it is state.switch_config.repos

print "pinned" "%s"
(if OpamPackage.Set.is_empty state.pinned then "0" else
let pinnings =
Expand Down
6 changes: 6 additions & 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
# all-repositories 1 (local)
# current-switch none set
### # empty switch
### opam switch create an-empty-switch --empty
Expand All @@ -50,6 +51,7 @@ Set to '"-removed"' the field solver-upgrade-criteria in global configuration
# install-criteria -removed
# upgrade-criteria -removed
# jobs 1
# all-repositories 1 (local)
# repositories 1 (local)
# pinned 0
# current-switch an-empty-switch
Expand Down Expand Up @@ -120,6 +122,7 @@ Done.
# install-criteria -removed
# upgrade-criteria -removed
# jobs 1
# all-repositories 2 (local)
# repositories 2 (local)
# pinned 1 (rsync)
# current-switch a-switch
Expand Down Expand Up @@ -152,6 +155,7 @@ Done.
# install-criteria -removed
# upgrade-criteria -removed
# jobs 1
# all-repositories 1 (local)
# repositories 1 (local)
# pinned 0
# current-switch an-empty-invariant-with-compiler
Expand Down Expand Up @@ -180,6 +184,7 @@ Done.
# install-criteria -removed
# upgrade-criteria -removed
# jobs 1
# all-repositories 1 (local)
# repositories 1 (local)
# pinned 0
# current-switch a-package-invariant
Expand Down Expand Up @@ -208,6 +213,7 @@ Done.
# install-criteria -removed
# upgrade-criteria -removed
# jobs 1
# all-repositories 1 (local)
# repositories 1 (local)
# pinned 0
# current-switch a-compiler-with-depopt
Expand Down
Loading