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

Add error in conan remove when using -p without a pattern that matches packages #13622

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 3 additions & 0 deletions conan/cli/commands/remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from conan.api.model import ListPattern
from conan.cli.command import conan_command, OnceArgument
from conans.client.userio import UserInput
from conans.errors import ConanException


@conan_command(group="Consumer")
Expand Down Expand Up @@ -36,6 +37,8 @@ def confirmation(message):
select_bundle = conan_api.list.select(ref_pattern, args.package_query, remote)

if ref_pattern.package_id is None:
if args.package_query is not None:
raise ConanException('--package-query supplied but the pattern does not match packages')
for ref, _ in select_bundle.refs():
if confirmation("Remove the recipe and all the packages of '{}'?"
"".format(ref.repr_notime())):
Expand Down
4 changes: 4 additions & 0 deletions conans/test/integration/command/remove_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,10 @@ def test_new_remove_package_revisions_expressions(populated_client, with_remote,
assert data.get("error_msg") in populated_client.out


def test_package_query_no_package_ref(populated_client):
populated_client.run("remove * -p 'compiler=clang'", assert_error=True)
AbrilRBS marked this conversation as resolved.
Show resolved Hide resolved


def _get_all_recipes(client, with_remote):
api = ConanAPI(client.cache_folder)
remote = api.remotes.get("default") if with_remote else None
Expand Down