Skip to content

Commit

Permalink
#178: Add pattern-prefix and ignore-untracked options
Browse files Browse the repository at this point in the history
  • Loading branch information
mtkennerly committed Apr 30, 2024
1 parent cc04085 commit eebbc26
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## Unreleased

* Added:
* `pattern-prefix` and `ignore-untracked` options.
* Changed:
* Updated Dunamai to 1.21.0+ for the latest features.

Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ In your pyproject.toml file, you may configure the following options:
```

Remember that backslashes must be escaped (`\\`) in the TOML file.
* `pattern-prefix` (string):
This will be inserted after the pattern's start anchor (`^`).
For example, to match tags like `some-package-v1.2.3`,
you can keep the default pattern and set the prefix to `some-package-`.
* `format` (string, default: unset):
This defines a custom output format for the version. Available substitutions:

Expand Down Expand Up @@ -215,6 +219,8 @@ In your pyproject.toml file, you may configure the following options:
* `fix-shallow-repository` (boolean, default: false):
If true, then automatically try to fix shallow repositories.
Currently, this only supports Git and will run `git fetch --unshallow`.
* `ignore-untracked` (boolean, default: false):
If true, ignore untracked files when determining whether the repository is dirty.
* `[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.
Expand Down
20 changes: 13 additions & 7 deletions poetry_dynamic_versioning/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
"vcs": str,
"dirty": bool,
"pattern": Optional[str],
"pattern-prefix": Optional[str],
"latest-tag": bool,
"substitution": _Substitution,
"files": Mapping[str, _File],
Expand All @@ -98,6 +99,7 @@
"tag-dir": str,
"strict": bool,
"fix-shallow-repository": bool,
"ignore-untracked": bool,
},
)
else:
Expand Down Expand Up @@ -182,6 +184,7 @@ def _default_config() -> Mapping:
"vcs": "any",
"dirty": False,
"pattern": None,
"pattern-prefix": None,
"latest-tag": False,
"substitution": {
"files": ["*.py", "*/__init__.py", "*/__version__.py", "*/_version.py"],
Expand All @@ -207,6 +210,7 @@ def _default_config() -> Mapping:
"tag-dir": "tags",
"strict": False,
"fix-shallow-repository": False,
"ignore-untracked": False,
}
}
}
Expand Down Expand Up @@ -415,13 +419,15 @@ def _get_version_from_dunamai(
vcs: Vcs, pattern: Union[str, Pattern], config: _Config, *, strict: Optional[bool] = None
) -> Version:
return Version.from_vcs(
vcs,
pattern,
config["latest-tag"],
config["tag-dir"],
config["tag-branch"],
config["full-commit"],
config["strict"] if strict is None else strict,
vcs=vcs,
pattern=pattern,
latest_tag=config["latest-tag"],
tag_dir=config["tag-dir"],
tag_branch=config["tag-branch"],
full_commit=config["full-commit"],
strict=config["strict"] if strict is None else strict,
pattern_prefix=config["pattern-prefix"],
ignore_untracked=config["ignore-untracked"],
)


Expand Down

0 comments on commit eebbc26

Please sign in to comment.