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

[1.2] fix(cache clear): normalize package name #6538

Merged
merged 1 commit into from
Sep 16, 2022
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: 2 additions & 1 deletion src/poetry/console/commands/cache/clear.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from cleo.helpers import argument
from cleo.helpers import option
from packaging.utils import canonicalize_name

from poetry.config.config import Config
from poetry.console.commands.command import Command
Expand Down Expand Up @@ -66,7 +67,7 @@ def handle(self) -> int:
"Add a specific version to clear"
)
elif len(parts) == 3:
package = parts[1]
package = canonicalize_name(parts[1])
version = parts[2]

if not cache.has(f"{package}:{version}"):
Expand Down
6 changes: 5 additions & 1 deletion tests/console/commands/cache/test_clear.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,16 @@ def test_cache_clear_all_no(
assert cache.has("cleo:0.2")


@pytest.mark.parametrize("package_name", ["cachy", "Cachy"])
def test_cache_clear_pkg(
tester: ApplicationTester,
repository_one: str,
cache: CacheManager,
package_name: str,
):
exit_code = tester.execute(f"cache clear {repository_one}:cachy:0.1", inputs="yes")
exit_code = tester.execute(
f"cache clear {repository_one}:{package_name}:0.1", inputs="yes"
)

assert exit_code == 0
assert tester.io.fetch_output() == ""
Expand Down