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 support for typed __version__ substitution. #64

Closed
wants to merge 1 commit into from
Closed
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
18 changes: 13 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,21 +179,29 @@ In your pyproject.toml file, you may configure the following options:
Example, if there have been 3 commits since the `v1.3.1` tag:
* PEP 440 with `bump = false`: `1.3.1.post3.dev0+28c1684`
* PEP 440 with `bump = true`: `1.3.2.dev3+28c1684`

* `[tool.poetry-dynamic-versioning.subversion]`: Options specific to Subversion.
* `tag-dir`: String. Default: `tags`. This is the location of tags relative
to the root.

* `[tool.poetry-dynamic-versioning.substitution]`: Insert the dynamic version
into additional files other than just pyproject.toml. These changes will be
reverted when the plugin deactivates.
* `files`: List of globs for any files that need substitutions. Default:
`["*.py", "*/__init__.py", "*/__version__.py", "*/_version.py"]`.

* `files`: List of globs for any files that need substitutions.

* Default: `["*.py", "*/__init__.py", "*/__version__.py", "*/_version.py"]`.
To disable substitution, set this to an empty list.

* `patterns`: List of regular expressions for the text to replace.
Each regular expression must have two capture groups, which are any
text to preserve before and after the replaced text. Default:
`["(^__version__\s*=\s*['\"])[^'\"]*(['\"])"]`.
text to preserve before and after the replaced text.

* Default: `[r"(^__version__\s*(?::\s*str)?\s*=\s*['\"])[^'\"]*(['\"])"]`.

* *Remember that the backslashes must be escaped (*`\\`*) in the TOML file.:*
i.e: `patterns = ["(^__version__\\s*(?::\\s*str)?\\s*=\\s*['\"])[^'\"]*(['\"])"]`.

Remember that the backslashes must be escaped (`\\`) in the TOML file.

Simple example:

Expand Down
2 changes: 1 addition & 1 deletion poetry_dynamic_versioning/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def _default_config() -> Mapping:
"subversion": {"tag-dir": "tags"},
"substitution": {
"files": ["*.py", "*/__init__.py", "*/__version__.py", "*/_version.py"],
"patterns": [r"(^__version__\s*=\s*['\"])[^'\"]*(['\"])"],
"patterns": [r"(^__version__\s*(?::\s*str)?\s*=\s*['\"])[^'\"]*(['\"])"],
},
"style": None,
"metadata": None,
Expand Down