New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

contribution that returns latest tags #462

Merged
merged 5 commits into from Nov 9, 2016

Conversation

Projects
None yet
2 participants
@mikofski
Contributor

mikofski commented Nov 1, 2016

Add a new Python module to contrib that contains one method, get_recent_tags() that returns tags, commits, authors and datetimes sorted new to old, to use as a versioneer in packages and with setup.py for Python packaging based on Git tags.

For example in Project/package/__init__.py:

"""
my Python package
"""

from dulwich.contrib import release_robot

__version__ = release_robot.get_current_version()  # trim 1st letter
__author__ = 'me'

For example in Project/setup.py:

from package import __version__, __name__, __author__

setup(name=__name__, version=__version__)

Uses the commit time to sort tags so that subsequent tag shuffling doesn't alter order. Also returns the commit SHA-1 and author name, in case that is desired for the version or release name.

For example fancy release name:

"""
my Python package
"""

from dulwich.contrib import release_robot

tag = release_robot.get_recent_tags()[0]
__version__ = tag[0][1:]  # trim 1st letter
__author__ = 'me'
__release__ = '%s-%s-%s-%s' % (
    tag[0], tag[1][0].strftime('%Y%m%d'), tag[1][1][:7], tag[1][2].rsplit(" ", 1)[0].replace(" ", "_")
)  # 'v0.3-20161031-4ffe1ec-Mark_Mikofski'

Signed-off-by: Mark Mikofski mark.mikofski@sunpowercorp.com

mikofski added some commits Nov 1, 2016

contribution that returns latest tags
* contains one method, get_recent_tags() that returns tags, commits
 authors and datetimes sorted new to old, to use as a versioneer in
 packages and with setup.py for Python packaging based on Git tags

Signed-off-by: Mark Mikofski <mark.mikofski@sunpowercorp.com>
update module docstring
if `latest_git_tags` is in `contrib` then why copy the file, just import it.
improve pattern for no leading or trailing text
* return None for no tags case
* more test cases

@jelmer jelmer merged commit 39f3605 into dulwich:master Nov 9, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@mikofski mikofski deleted the mikofski:versioneer branch Nov 9, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment