Skip to content

Commit 8b6d4a1

Browse files
author
MousaZeidBaker
authored
Merge pull request #20 from KotlinIsland/feat/preserve_tilde
(🎁) Preserve tilde when bumping
2 parents 52118f5 + b346042 commit 8b6d4a1

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

src/poetry_plugin_up/command.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,15 @@ def handle_dependency(
134134
self.line(f"No new version for '{dependency.name}'")
135135
return
136136

137-
new_version = "^" + candidate.pretty_version
137+
if (
138+
dependency.pretty_constraint[0] == "~"
139+
and "." in dependency.pretty_constraint
140+
):
141+
new_version = "~" + candidate.pretty_version
142+
else:
143+
new_version = "^" + candidate.pretty_version
138144
if not latest:
139-
if dependency.pretty_constraint[0] == "~":
140-
new_version = "~" + candidate.pretty_version
141-
elif dependency.pretty_constraint[:2] == ">=":
145+
if dependency.pretty_constraint[:2] == ">=":
142146
new_version = ">=" + candidate.pretty_version
143147

144148
self.bump_version_in_pyproject_content(

tests/fixtures/simple_project/expected_pyproject_with_latest.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ waldo = {git = "https://example.com/test/project.git"}
1818
[tool.poetry.group.dev.dependencies]
1919
fred = "1.1.1"
2020
plugh = "^2.2.2"
21-
xyzzy = "^2.2.2"
21+
xyzzy = "~2.2.2"
2222
nacho = "^2.2.2"
2323
thud = "^2.2.2"
2424

tests/fixtures/simple_project/expected_pyproject_with_latest_and_pinned.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ waldo = {git = "https://example.com/test/project.git"}
1818
[tool.poetry.group.dev.dependencies]
1919
fred = "^2.2.2"
2020
plugh = "^2.2.2"
21-
xyzzy = "^2.2.2"
21+
xyzzy = "~2.2.2"
2222
nacho = "^2.2.2"
2323
thud = "^2.2.2"
2424

0 commit comments

Comments
 (0)