Skip to content

Commit

Permalink
Don't display any notes about removed repositories when no repositori…
Browse files Browse the repository at this point in the history
…es have been removed
  • Loading branch information
kit-ty-kate committed Aug 12, 2024
1 parent e10201b commit 935929f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions master_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ users)

## Repository
* Check that the repositories given to `opam repository remove` actually exist [#5014 @kit-ty-kate - fixes #5012]
* Don't display any notes about removed repositories when no repositories have been removed [#5014 @kit-ty-kate]

## Lock

Expand Down
5 changes: 4 additions & 1 deletion src/client/opamCommands.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2421,6 +2421,7 @@ let repository cli =
let full_wipe = List.mem `All scope in
let global = global || full_wipe in
let unknown_repos = ref (if full_wipe then [] else names) in
let has_known_repos = ref false in
let rm =
List.filter (fun n ->
let seen =
Expand All @@ -2431,6 +2432,8 @@ let repository cli =
List.filter
(fun n' -> not (OpamRepositoryName.equal n n'))
!unknown_repos;
if seen && not !has_known_repos then
has_known_repos := true;
not seen)
in
let gt =
Expand All @@ -2445,7 +2448,7 @@ let repository cli =
"No configured repositories by these names found: %s");
OpamRepositoryState.drop @@
List.fold_left OpamRepositoryCommand.remove rt names
else if scope = [`Current_switch] then
else if scope = [`Current_switch] && !has_known_repos then
OpamConsole.msg
"Repositories removed from the selections of switch %s. \
Use '--all' to forget about them altogether.\n"
Expand Down
1 change: 0 additions & 1 deletion tests/reftests/repository.test
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,6 @@ to-many-commits git+file://${BASEDIR}/TMCS repos(1/3)
2 oper3 file://${BASEDIR}/OPER3
3 oper file://${BASEDIR}/OPER3
### opam repository remove does-not-exist
Repositories removed from the selections of switch repos. Use '--all' to forget about them altogether.
[WARNING] Repository 'does-not-exist' not found in the current switch, ignoring
### opam repository remove does-not-exist --all
[WARNING] No configured repositories by these names found: does-not-exist
Expand Down

0 comments on commit 935929f

Please sign in to comment.