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 16, 2024
1 parent 8066971 commit dc29f65
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 @@ -69,6 +69,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 @@ -618,7 +618,6 @@ to-many-commits
oper3
oper
### 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 dc29f65

Please sign in to comment.