-
enable
(boolean, default: false):
Since the plugin has to be installed globally,
this setting is an opt-in per project.
-
vcs
(string, default: any
):
This is the version control system to check for a version.
One of: any
, git
, mercurial
, darcs
, bazaar
, subversion
, fossil
, pijul
.
-
metadata
(boolean, default: unset):
If true, include the commit hash in the version,
and also include a dirty flag if dirty
is true.
If unset, metadata will only be included if you are on a commit without a version tag.
This is ignored when format
or format-jinja
is used.
-
tagged-metadata
(boolean, default: false):
If true, include any tagged metadata discovered as the first part of the metadata segment.
Has no effect when metadata
is set to false.
This is ignored when format
or format-jinja
is used.
-
dirty
(boolean, default: false):
If true, include a dirty flag in the metadata,
indicating whether there are any uncommitted changes.
Has no effect when metadata
is set to false.
This is ignored when format
or format-jinja
is used.
-
pattern
(string):
This is a regular expression which will be used to find a tag representing a version.
When this is unset, Dunamai's default pattern is used.
There must be a capture group named base
with the main part of the version.
Optionally, it may contain another two groups named stage
and revision
for prereleases,
and it may contain a group named tagged_metadata
to be used with the tagged-metadata
option.
There may also be a group named epoch
for the PEP 440 concept.
If the base
group is not included,
then this will be interpreted as a named preset from the Dunamai Pattern
class.
This includes: default
, default-unprefixed
(makes the v
prefix optional).
You can check the default for your installed version of Dunamai by running this command:
poetry run python -c "import dunamai; print(dunamai.Pattern.Default.regex())"
Remember that backslashes must be escaped in the TOML file.
pattern = '(?P<base>\d+\.\d+\.\d+)'
pattern = "default-unprefixed"
-
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:
{base}
{stage}
{revision}
{distance}
{commit}
{dirty}
{tagged_metadata}
{branch}
{branch_escaped}
which omits any non-letter/number characters{timestamp}
of the current commit, which expands to YYYYmmddHHMMSS as UTC
Example: v{base}+{distance}.{commit}
-
format-jinja
(string, default: unset):
This defines a custom output format for the version,
using a Jinja template.
When this is set, format
is ignored.
Available variables:
base
(string)stage
(string or None)revision
(integer or None)distance
(integer)commit
(string)dirty
(boolean)tagged_metadata
(string or None)version
(dunumai.Version)env
(dictionary of environment variables)branch
(string or None)branch_escaped
(string or None)timestamp
(string or None)
Available functions:
Simple example:
format-jinja = "{% if distance == 0 %}{{ base }}{% else %}{{ base }}+{{ distance }}.{{ commit }}{% endif %}"
Complex example:
format-jinja = """
{%- if distance == 0 -%}
{{ serialize_pep440(base, stage, revision) }}
{%- elif revision is not none -%}
{{ serialize_pep440(base, stage, revision + 1, dev=distance, metadata=[commit]) }}
{%- else -%}
{{ serialize_pep440(bump_version(base), stage, revision, dev=distance, metadata=[commit]) }}
{%- endif -%}
"""
-
format-jinja-imports
(array of tables, default: empty):
This defines additional things to import and make available to the format-jinja
template.
Each table must contain a module
key and may also contain an item
key. Consider this example:
format-jinja-imports = [
{ module = "foo" },
{ module = "bar", item = "baz" },
]
This is roughly equivalent to:
import foo
from bar import baz
foo
and baz
would then become available in the Jinja formatting.
-
style
(string, default: unset):
One of: pep440
, semver
, pvp
.
These are preconfigured output formats.
If you set both a style
and a format
,
then the format will be validated against the style's rules.
If style
is unset, the default output format will follow PEP 440,
but a custom format
will only be validated if style
is set explicitly.
-
latest-tag
(boolean, default: false):
If true, then only check the latest tag for a version,
rather than looking through all the tags until a suitable one is found to match the pattern
.
-
bump
(boolean, default: false):
If true, then increment the last part of the version base
by 1,
unless the stage
is set,
in which case increment the revision
by 1 or set it to a default of 2 if there was no revision
.
Does nothing when on a commit with a version tag.
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
-
tag-dir
(string, default: tags
):
This is the location of tags relative to the root.
This is only used for Subversion.
-
tag-branch
(string, default: unset):
Branch on which to find tags, if different than the 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.
-
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.