Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
python-poetry
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
python-poetry
Commits
c4e1b218
Unverified
Commit
c4e1b218
authored
May 16, 2022
by
Etty
Committed by
GitHub
May 16, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add --dry-run option to version command
Resolves: #5074
parent
f0f5ae22
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
6 deletions
+24
-6
docs/cli.md
+1
-0
src/poetry/console/commands/version.py
+14
-6
tests/console/commands/test_version.py
+9
-0
No files found.
docs/cli.md
View file @
c4e1b218
...
@@ -623,6 +623,7 @@ The table below illustrates the effect of these rules with concrete examples.
...
@@ -623,6 +623,7 @@ The table below illustrates the effect of these rules with concrete examples.
### Options
### Options
* `
--short (-s)
`: Output the version number only.
* `
--short (-s)
`: Output the version number only.
* `
--dry-run
`: Do not update pyproject.toml file.
## export
## export
...
...
src/poetry/console/commands/version.py
View file @
c4e1b218
...
@@ -29,7 +29,14 @@ class VersionCommand(Command):
...
@@ -29,7 +29,14 @@ class VersionCommand(Command):
optional
=
True
,
optional
=
True
,
)
)
]
]
options
=
[
option
(
"short"
,
"s"
,
"Output the version number only"
)]
options
=
[
option
(
"short"
,
"s"
,
"Output the version number only"
),
option
(
"dry-run"
,
None
,
"Do not update pyproject.toml file"
,
),
]
help
=
"""
\
help
=
"""
\
The version command shows the current version of the project or bumps the version of
The version command shows the current version of the project or bumps the version of
...
@@ -66,12 +73,13 @@ patch, minor, major, prepatch, preminor, premajor, prerelease.
...
@@ -66,12 +73,13 @@ patch, minor, major, prepatch, preminor, premajor, prerelease.
f
" to <fg=green>{version}</>"
f
" to <fg=green>{version}</>"
)
)
content
:
dict
[
str
,
Any
]
=
self
.
poetry
.
file
.
read
()
if
not
self
.
option
(
"dry-run"
):
poetry_content
=
content
[
"tool"
][
"poetry"
]
content
:
dict
[
str
,
Any
]
=
self
.
poetry
.
file
.
read
()
poetry_content
[
"version"
]
=
version
.
text
poetry_content
=
content
[
"tool"
][
"poetry"
]
poetry_content
[
"version"
]
=
version
.
text
assert
isinstance
(
content
,
TOMLDocument
)
assert
isinstance
(
content
,
TOMLDocument
)
self
.
poetry
.
file
.
write
(
content
)
self
.
poetry
.
file
.
write
(
content
)
else
:
else
:
if
self
.
option
(
"short"
):
if
self
.
option
(
"short"
):
self
.
line
(
self
.
poetry
.
package
.
pretty_version
)
self
.
line
(
self
.
poetry
.
package
.
pretty_version
)
...
...
tests/console/commands/test_version.py
View file @
c4e1b218
...
@@ -76,3 +76,12 @@ def test_version_update(tester: CommandTester):
...
@@ -76,3 +76,12 @@ def test_version_update(tester: CommandTester):
def
test_short_version_update
(
tester
:
CommandTester
):
def
test_short_version_update
(
tester
:
CommandTester
):
tester
.
execute
(
"--short 2.0.0"
)
tester
.
execute
(
"--short 2.0.0"
)
assert
tester
.
io
.
fetch_output
()
==
"2.0.0
\n
"
assert
tester
.
io
.
fetch_output
()
==
"2.0.0
\n
"
def
test_dry_run
(
tester
:
CommandTester
):
old_pyproject
=
tester
.
command
.
poetry
.
file
.
path
.
read_text
()
tester
.
execute
(
"--dry-run major"
)
new_pyproject
=
tester
.
command
.
poetry
.
file
.
path
.
read_text
()
assert
tester
.
io
.
fetch_output
()
==
"Bumping version from 1.2.3 to 2.0.0
\n
"
assert
old_pyproject
==
new_pyproject
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment