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

Added downgrading note when updating to an older version #8176

Merged
merged 3 commits into from
Jul 18, 2023
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
13 changes: 9 additions & 4 deletions src/poetry/installation/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,13 +461,18 @@ def get_operation_message(
)

if isinstance(operation, Update):
initial_version = (initial_pkg := operation.initial_package).version
target_version = (target_pkg := operation.target_package).version
update_kind = (
"Updating" if target_version >= initial_version else "Downgrading"
)
return (
f"<{base_tag}>Updating"
f" <{package_color}>{operation.initial_package.name}</{package_color}> "
f"<{base_tag}>{update_kind}"
f" <{package_color}>{initial_pkg.name}</{package_color}> "
f"(<{source_operation_color}>"
f"{operation.initial_package.full_pretty_version}"
f"{initial_pkg.full_pretty_version}"
f"</{source_operation_color}> -> <{operation_color}>"
f"{operation.target_package.full_pretty_version}</>)</>"
f"{target_pkg.full_pretty_version}</>)</>"
)
return ""

Expand Down
10 changes: 6 additions & 4 deletions tests/installation/test_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ def test_execute_executes_a_batch_of_operations(
Install(Package("pytest", "3.5.1")),
Uninstall(Package("attrs", "17.4.0")),
Update(Package("requests", "2.18.3"), Package("requests", "2.18.4")),
Update(Package("pytest", "3.5.1"), Package("pytest", "3.5.0")),
Uninstall(Package("clikit", "0.2.3")).skip("Not currently installed"),
Install(file_package),
Install(directory_package),
Expand All @@ -254,11 +255,12 @@ def test_execute_executes_a_batch_of_operations(
)

expected = f"""
Package operations: 4 installs, 1 update, 1 removal
Package operations: 4 installs, 2 updates, 1 removal

• Installing pytest (3.5.1)
• Removing attrs (17.4.0)
• Updating requests (2.18.3 -> 2.18.4)
• Downgrading pytest (3.5.1 -> 3.5.0)
• Installing demo (0.1.0 {file_package.source_url})
• Installing simple-project (1.2.3 {directory_package.source_url})
• Installing demo (0.1.0 master)
Expand All @@ -267,9 +269,9 @@ def test_execute_executes_a_batch_of_operations(
expected_lines = set(expected.splitlines())
output_lines = set(io.fetch_output().splitlines())
assert output_lines == expected_lines
assert wheel_install.call_count == 5
# Two pip uninstalls: one for the remove operation one for the update operation
assert len(env.executed) == 2
assert wheel_install.call_count == 6
# 3 pip uninstalls: one for the remove operation and two for the update operations
assert len(env.executed) == 3
assert return_code == 0

assert prepare_spy.call_count == 2
Expand Down
Loading