Skip to content

Commit

Permalink
Merge pull request #176 from jenshnielsen/upgrade_versioneer
Browse files Browse the repository at this point in the history
upgrade versioneer to 0.19
  • Loading branch information
jenshnielsen committed Feb 18, 2021
2 parents 130b8b4 + 8030836 commit 58acd3c
Show file tree
Hide file tree
Showing 2 changed files with 116 additions and 78 deletions.
25 changes: 15 additions & 10 deletions plottr/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# that just contains the computed version number.

# This file is released into the public domain. Generated by
# versioneer-0.18 (https://github.com/warner/python-versioneer)
# versioneer-0.19 (https://github.com/python-versioneer/python-versioneer)

"""Git implementation of _version.py."""

Expand Down Expand Up @@ -57,7 +57,7 @@ class NotThisMethod(Exception):


def register_vcs_handler(vcs, method): # decorator
"""Decorator to mark a method as the handler for a particular VCS."""
"""Create decorator to mark a method as the handler of a VCS."""
def decorate(f):
"""Store f in HANDLERS[vcs][method]."""
if vcs not in HANDLERS:
Expand Down Expand Up @@ -93,9 +93,7 @@ def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False,
if verbose:
print("unable to find command, tried %s" % (commands,))
return None, None
stdout = p.communicate()[0].strip()
if sys.version_info[0] >= 3:
stdout = stdout.decode()
stdout = p.communicate()[0].strip().decode()
if p.returncode != 0:
if verbose:
print("unable to run %s (error)" % dispcmd)
Expand Down Expand Up @@ -165,6 +163,10 @@ def git_versions_from_keywords(keywords, tag_prefix, verbose):
raise NotThisMethod("no keywords at all, weird")
date = keywords.get("date")
if date is not None:
# Use only the last line. Previous lines may contain GPG signature
# information.
date = date.splitlines()[-1]

# git-2.2.0 added "%cI", which expands to an ISO-8601 -compliant
# datestamp. However we prefer "%ci" (which expands to an "ISO-8601
# -like" string, which we must then edit to make compliant), because
Expand Down Expand Up @@ -300,6 +302,9 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command):
# commit date: see ISO-8601 comment in git_versions_from_keywords()
date = run_command(GITS, ["show", "-s", "--format=%ci", "HEAD"],
cwd=root)[0].strip()
# Use only the last line. Previous lines may contain GPG signature
# information.
date = date.splitlines()[-1]
pieces["date"] = date.strip().replace(" ", "T", 1).replace(" ", "", 1)

return pieces
Expand Down Expand Up @@ -338,18 +343,18 @@ def render_pep440(pieces):


def render_pep440_pre(pieces):
"""TAG[.post.devDISTANCE] -- No -dirty.
"""TAG[.post0.devDISTANCE] -- No -dirty.
Exceptions:
1: no tags. 0.post.devDISTANCE
1: no tags. 0.post0.devDISTANCE
"""
if pieces["closest-tag"]:
rendered = pieces["closest-tag"]
if pieces["distance"]:
rendered += ".post.dev%d" % pieces["distance"]
rendered += ".post0.dev%d" % pieces["distance"]
else:
# exception #1
rendered = "0.post.dev%d" % pieces["distance"]
rendered = "0.post0.dev%d" % pieces["distance"]
return rendered


Expand Down Expand Up @@ -385,7 +390,7 @@ def render_pep440_old(pieces):
The ".dev0" means dirty.
Eexceptions:
Exceptions:
1: no tags. 0.postDISTANCE[.dev0]
"""
if pieces["closest-tag"]:
Expand Down

0 comments on commit 58acd3c

Please sign in to comment.