From d35f5117fc64a17fdcf9eb9b19ba363d33511a17 Mon Sep 17 00:00:00 2001 From: Manuel Barkhau Date: Fri, 21 Dec 2018 19:22:50 +0100 Subject: [PATCH] fix tag vcs parsing and output --- src/pycalver/__main__.py | 8 ++++++-- src/pycalver/vcs.py | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/pycalver/__main__.py b/src/pycalver/__main__.py index 8a7f5ca..19165ce 100644 --- a/src/pycalver/__main__.py +++ b/src/pycalver/__main__.py @@ -107,11 +107,15 @@ def _update_cfg_from_vcs(cfg: config.Config, fetch: bool) -> config.Config: if version_tags: version_tags.sort(reverse=True) log.debug(f"found {len(version_tags)} tags: {version_tags[:2]}") - latest_version_tag = version_tags[0] + latest_version_tag = version_tags[0] + latest_version_pep440 = version.pycalver_to_pep440(latest_version_tag) if latest_version_tag > cfg.current_version: log.info(f"Working dir version : {cfg.current_version}") log.info(f"Latest version from {_vcs.name:>3} tag: {latest_version_tag}") - cfg = cfg._replace(current_version=latest_version_tag) + cfg = cfg._replace( + current_version=latest_version_tag, pep440_version=latest_version_pep440 + ) + else: log.debug("no vcs tags found") except OSError: diff --git a/src/pycalver/vcs.py b/src/pycalver/vcs.py index f30563d..9176a81 100644 --- a/src/pycalver/vcs.py +++ b/src/pycalver/vcs.py @@ -115,7 +115,9 @@ class VCS: """List vcs tags on all branches.""" ls_tag_lines = self('ls_tags').splitlines() log.debug(f"ls_tags output {ls_tag_lines}") - return [line.strip() for line in ls_tag_lines if line.strip().startswith("v")] + return [ + line.strip().split(" ", 1)[0] for line in ls_tag_lines if line.strip().startswith("v") + ] def add(self, path: str) -> None: """Add updates to be included in next commit."""