Skip to content

Commit 68b8385

Browse files
committed
Update Dunamai dependency and integrate new features
1 parent bcca51f commit 68b8385

File tree

5 files changed

+29
-15
lines changed

5 files changed

+29
-15
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* Added:
44
* The `bump` config may now be set to a table,
55
which supports an `index` field.
6+
* `commit-length` option to set a fixed length for commit hashes.
7+
* `{major}`, `{minor}`, and `{patch}` format placeholders.
68
* Fixed:
79
* Compatibility with other plugins (such as `poetry-monoranger-plugin`)
810
that replace the `ConsoleCommandEvent.command.poetry` instance.

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@ In your pyproject.toml file, you may configure the following options:
147147
* `{branch}`
148148
* `{branch_escaped}` which omits any non-letter/number characters
149149
* `{timestamp}` of the current commit, which expands to YYYYmmddHHMMSS as UTC
150+
* `{major}` (first part of `base` split on `.`, or 0)
151+
* `{minor}` (second part of `base` split on `.`, or 0)
152+
* `{patch}` (third part of `base` split on `.`, or 0)
150153
151154
Example: `v{base}+{distance}.{commit}`
152155
* `format-jinja` (string, default: unset):
@@ -168,6 +171,9 @@ In your pyproject.toml file, you may configure the following options:
168171
* `branch` (string or None)
169172
* `branch_escaped` (string or None)
170173
* `timestamp` (string or None)
174+
* `major` (integer)
175+
* `minor` (integer)
176+
* `patch` (integer)
171177
172178
Available functions:
173179
@@ -261,6 +267,8 @@ In your pyproject.toml file, you may configure the following options:
261267
Currently, this only supports Git and will run `git fetch --unshallow`.
262268
* `ignore-untracked` (boolean, default: false):
263269
If true, ignore untracked files when determining whether the repository is dirty.
270+
* `commit-length` (integer, default: unset):
271+
Use this many characters from the start of the full commit hash.
264272
* `[tool.poetry-dynamic-versioning.substitution]`:
265273
Insert the dynamic version into additional files other than just pyproject.toml.
266274
These changes will be reverted when the plugin deactivates.

poetry.lock

Lines changed: 4 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

poetry_dynamic_versioning/__init__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@
119119
"strict": bool,
120120
"fix-shallow-repository": bool,
121121
"ignore-untracked": bool,
122+
"commit-length": Optional[int],
122123
"from-file": _FromFile,
123124
},
124125
)
@@ -251,6 +252,7 @@ def _default_config() -> Mapping:
251252
"strict": False,
252253
"fix-shallow-repository": False,
253254
"ignore-untracked": False,
255+
"commit-length": None,
254256
"from-file": {
255257
"source": None,
256258
"pattern": None,
@@ -394,6 +396,14 @@ def _render_jinja(version: Version, template: str, config: _Config, extra: Optio
394396

395397
if bump_config.enable and version.distance > 0:
396398
version = version.bump(index=bump_config.index)
399+
400+
def base_part(index: int) -> int:
401+
parts = version.base.split(".")
402+
try:
403+
return int(parts[index])
404+
except Exception:
405+
return 0
406+
397407
default_context = {
398408
"base": version.base,
399409
"version": version,
@@ -405,6 +415,9 @@ def _render_jinja(version: Version, template: str, config: _Config, extra: Optio
405415
"branch": version.branch,
406416
"branch_escaped": _escape_branch(version.branch),
407417
"timestamp": _format_timestamp(version.timestamp),
418+
"major": base_part(0),
419+
"minor": base_part(1),
420+
"patch": base_part(2),
408421
"env": os.environ,
409422
"bump_version": bump_version,
410423
"tagged_metadata": version.tagged_metadata,
@@ -493,6 +506,7 @@ def _get_version_from_dunamai(
493506
strict=config["strict"] if strict is None else strict,
494507
pattern_prefix=config["pattern-prefix"],
495508
ignore_untracked=config["ignore-untracked"],
509+
commit_length=config["commit-length"],
496510
)
497511

498512

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ include = [
2727

2828
[tool.poetry.dependencies]
2929
python = "^3.7"
30-
dunamai = "^1.21.0"
30+
dunamai = "^1.23.0"
3131
tomlkit = ">= 0.4"
3232
jinja2 = ">=2.11.1, <4"
3333
poetry = { version = ">=1.2.0", optional = true }

0 commit comments

Comments
 (0)