Skip to content

Commit 7d14d4b

Browse files
committed
opam config report: add the list of all installed repositories
1 parent c12b9d0 commit 7d14d4b

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

master_changes.md

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ users)
2222
## Init
2323

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

2627
## Actions
2728

src/client/opamCommands.ml

+12-7
Original file line numberDiff line numberDiff line change
@@ -1487,12 +1487,9 @@ let config cli =
14871487
if n <> 0 then [Printf.sprintf "%d (%s)" n label]
14881488
else [] in
14891489
print "jobs" "%d" (Lazy.force OpamStateConfig.(!r.jobs));
1490-
match OpamStateConfig.get_switch_opt () with
1491-
| None -> print "current-switch" "%s" "none set"; `Ok ()
1492-
| Some switch ->
1493-
OpamSwitchState.with_ `Lock_none ~switch gt @@ fun state ->
1494-
print "repositories" "%s"
1495-
(let repos = state.switch_repos.repositories in
1490+
let print_repositories name rt =
1491+
print name "%s"
1492+
(let repos = rt.repositories in
14961493
let default, nhttp, nlocal, nvcs =
14971494
OpamRepositoryName.Map.fold
14981495
(fun _ repo (dft, nhttp, nlocal, nvcs) ->
@@ -1502,7 +1499,7 @@ let config cli =
15021499
then
15031500
OpamRepositoryName.Map.find
15041501
repo.repo_name
1505-
state.switch_repos.repos_definitions |>
1502+
rt.repos_definitions |>
15061503
OpamFile.Repo.stamp
15071504
else dft
15081505
in
@@ -1520,6 +1517,14 @@ let config cli =
15201517
| Some v -> Printf.sprintf " (default repo at %s)" v
15211518
| None -> ""
15221519
);
1520+
in
1521+
OpamRepositoryState.with_ `Lock_none gt @@ fun rt ->
1522+
print_repositories "all-repositories" rt;
1523+
match OpamStateConfig.get_switch_opt () with
1524+
| None -> print "current-switch" "%s" "none set"; `Ok ()
1525+
| Some switch ->
1526+
OpamSwitchState.with_ `Lock_none ~switch gt @@ fun state ->
1527+
print_repositories "repositories" state.switch_repos;
15231528
print "pinned" "%s"
15241529
(if OpamPackage.Set.is_empty state.pinned then "0" else
15251530
let pinnings =

tests/reftests/config.test

+6
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ Set to '"-removed"' the field solver-upgrade-criteria in global configuration
3838
# install-criteria -removed
3939
# upgrade-criteria -removed
4040
# jobs 1
41+
# all-repositories 1 (local)
4142
# current-switch none set
4243
### # empty switch
4344
### opam switch create an-empty-switch --empty
@@ -50,6 +51,7 @@ Set to '"-removed"' the field solver-upgrade-criteria in global configuration
5051
# install-criteria -removed
5152
# upgrade-criteria -removed
5253
# jobs 1
54+
# all-repositories 1 (local)
5355
# repositories 1 (local)
5456
# pinned 0
5557
# current-switch an-empty-switch
@@ -120,6 +122,7 @@ Done.
120122
# install-criteria -removed
121123
# upgrade-criteria -removed
122124
# jobs 1
125+
# all-repositories 2 (local)
123126
# repositories 2 (local)
124127
# pinned 1 (rsync)
125128
# current-switch a-switch
@@ -152,6 +155,7 @@ Done.
152155
# install-criteria -removed
153156
# upgrade-criteria -removed
154157
# jobs 1
158+
# all-repositories 1 (local)
155159
# repositories 1 (local)
156160
# pinned 0
157161
# current-switch an-empty-invariant-with-compiler
@@ -180,6 +184,7 @@ Done.
180184
# install-criteria -removed
181185
# upgrade-criteria -removed
182186
# jobs 1
187+
# all-repositories 1 (local)
183188
# repositories 1 (local)
184189
# pinned 0
185190
# current-switch a-package-invariant
@@ -208,6 +213,7 @@ Done.
208213
# install-criteria -removed
209214
# upgrade-criteria -removed
210215
# jobs 1
216+
# all-repositories 1 (local)
211217
# repositories 1 (local)
212218
# pinned 0
213219
# current-switch a-compiler-with-depopt

0 commit comments

Comments
 (0)