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 all commits
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
5 changes: 5 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,11 @@ 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
assert "--package-query supplied but the pattern does not match packages" in populated_client.out


def _get_all_recipes(client, with_remote):
api = ConanAPI(client.cache_folder)
remote = api.remotes.get("default") if with_remote else None
Expand Down
4 changes: 2 additions & 2 deletions conans/test/integration/settings/settings_override_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def test_exclude_patterns_settings():
client.run("create zlib --name zlib --version 1.0")
client.run("create openssl --name openssl --version 1.0")

# We miss openss and zlib debug packages
# We miss openssl and zlib debug packages
client.run("install consumer -s build_type=Debug", assert_error=True)
assert "ERROR: Missing prebuilt package for 'openssl/1.0', 'zlib/1.0'" in client.out

Expand All @@ -100,7 +100,7 @@ def test_exclude_patterns_settings():
client.run("install --requires consumer/1.0 -s consumer/*:build_type=Debug")

# Priority between package scoped settings
client.run('remove consumer/*#* -p="build_type=Debug" -c')
client.run('remove consumer/*#* -c')
client.run("install --reference consumer/1.0 -s build_type=Debug", assert_error=True)
# Pre-check, there is no Debug package for any of them
assert "ERROR: Missing prebuilt package for 'consumer/1.0', 'openssl/1.0', 'zlib/1.0'"
Expand Down