Skip to content
Open
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
8 changes: 7 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ this package allows to extract it from the underlying Git repository:

setup(
name='foobar',
version_format='{tag}.dev{commitcount}+{gitsha}',
version_format='{tag}.dev{commitcount}+{gitsha}-{dirty}',
setup_requires=['setuptools-git-version'],
...)

Expand All @@ -36,6 +36,7 @@ Fields
* ``tag``: The latest tag (probably a release version like ``v1.0.3``) in your repository
* ``commitcount``: The number of additional commits on top of this tag (e.g. ``13``)
* ``gitsha``: An abbreviated commit hash of the latest commit in your repository
* ``dirty``: Result of the --dirty git option

Implementation Details
----------------------
Expand All @@ -53,6 +54,11 @@ your repository
Changes
-------

1.0.5 - 2019-07-17
++++++++++++++++++

- [feature] added dirty to version_format

1.0.4 - 2016-06-22
++++++++++++++++++

Expand Down
4 changes: 2 additions & 2 deletions setuptools_git_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@


command = 'git describe --tags --long --dirty'
fmt = '{tag}.{commitcount}+{gitsha}'
fmt = '{tag}.{commitcount}+{gitsha}-{dirty}'


def validate_version_format(dist, attr, value):
Expand All @@ -23,7 +23,7 @@ def format_version(version, fmt=fmt):
tag, count, sha = parts[:3]
if count == '0' and not dirty:
return tag
return fmt.format(tag=tag, commitcount=count, gitsha=sha.lstrip('g'))
return fmt.format(tag=tag, commitcount=count, gitsha=sha.lstrip('g'), dirty='Dirty' if dirty else '')


def get_git_version():
Expand Down