From 2d683a7d632580171a8c7ce0d22013a51cfb46ef Mon Sep 17 00:00:00 2001 From: mtkennerly Date: Mon, 7 Nov 2022 09:18:36 +0800 Subject: [PATCH] #98: Add 'strict 'option --- CHANGELOG.md | 1 + README.md | 2 ++ poetry_dynamic_versioning/__init__.py | 2 ++ 3 files changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ba3a378..4ee88d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ * Added: * The plugin now prints a warning if its configuration is invalid. Right now, this just checks for unknown keys. + * A `strict` option to prevent falling back to `0.0.0` when there are no tags. * Changed: * Updated Dunamai to 1.14.0+ for the latest features. This adds support for VCS archival files, namely ones produced by `git archive` and `hg archive`. diff --git a/README.md b/README.md index 5eafbc5..7ef2273 100644 --- a/README.md +++ b/README.md @@ -190,6 +190,8 @@ In your pyproject.toml file, you may configure the following options: current branch. This is only used for Git currently. * `full-commit` (boolean, default: false): If true, get the full commit hash instead of the short form. This is only used for Git and Mercurial. + * `strict` (boolean, default: false): + If true, then fail instead of falling back to 0.0.0 when there are no tags. * `[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. diff --git a/poetry_dynamic_versioning/__init__.py b/poetry_dynamic_versioning/__init__.py index 6128144..8ce8e9b 100644 --- a/poetry_dynamic_versioning/__init__.py +++ b/poetry_dynamic_versioning/__init__.py @@ -81,6 +81,7 @@ def _default_config() -> Mapping: "full-commit": False, "tag-branch": None, "tag-dir": "tags", + "strict": False, } } } @@ -200,6 +201,7 @@ def _get_version(config: Mapping) -> str: config["tag-dir"], config["tag-branch"], config["full-commit"], + config["strict"], ) if config["format-jinja"]: