From dc29f658de99673f835d0298e32f7965e02c47ba Mon Sep 17 00:00:00 2001 From: Kate Date: Mon, 12 Aug 2024 22:21:37 +0100 Subject: [PATCH] Don't display any notes about removed repositories when no repositories have been removed --- master_changes.md | 1 + src/client/opamCommands.ml | 5 ++++- tests/reftests/repository.test | 1 - 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/master_changes.md b/master_changes.md index 6fc22ee3a6e..476779f01e3 100644 --- a/master_changes.md +++ b/master_changes.md @@ -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 diff --git a/src/client/opamCommands.ml b/src/client/opamCommands.ml index b91818bbac6..a85a11a3a09 100644 --- a/src/client/opamCommands.ml +++ b/src/client/opamCommands.ml @@ -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 = @@ -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 = @@ -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" diff --git a/tests/reftests/repository.test b/tests/reftests/repository.test index 03ad15a8fbb..940d375f248 100644 --- a/tests/reftests/repository.test +++ b/tests/reftests/repository.test @@ -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