From 56ee7b103d58ef87cdb8bb4915b038e1d6b02b2f Mon Sep 17 00:00:00 2001 From: Derek DeJonghe Date: Mon, 15 Jun 2020 17:15:54 -0400 Subject: [PATCH] only look for new version if doing format --- semver/get_version.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/semver/get_version.py b/semver/get_version.py index 4bb7f07..56c9125 100644 --- a/semver/get_version.py +++ b/semver/get_version.py @@ -21,19 +21,19 @@ def get_version(build=0,version_format=None,dot=False): logger.debug("v_hash and c_hash do not match!") branch = subprocess.Popen(['git', 'rev-parse', '--abbrev-ref', 'HEAD'], stdout=subprocess.PIPE, stderr=DEVNULL, cwd='.').stdout.read().decode('utf-8').rstrip() - # Find the next version - semver = SemVer() - semver.merged_branch = branch - version_type = semver.get_version_type() - p = subprocess.Popen(['bumpversion', '--dry-run', '--verbose', '--current-version', get_tag_version(), version_type], stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd='.') - bump_output = p.stderr.read().decode() - next_version = match = re.search("New version will be '([0-9]*.[0-9]*.[0-9]*)'", bump_output).group(1) - - if version_format == 'npm': - return "{}-{}.{}".format(next_version,branch.replace('/','-'),build) - if version_format == 'maven': - qualifier = 'SNAPSHOT' if build == 0 else build - return "{}-{}-{}".format(next_version,branch.replace('/','-'),qualifier) + if version_format: + semver = SemVer() + semver.merged_branch = branch + version_type = semver.get_version_type() + p = subprocess.Popen(['bumpversion', '--dry-run', '--verbose', '--current-version', get_tag_version(), version_type], stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd='.') + bump_output = p.stderr.read().decode() + next_version = match = re.search("New version will be '([0-9]*.[0-9]*.[0-9]*)'", bump_output).group(1) + + if version_format == 'npm': + return "{}-{}.{}".format(next_version,branch.replace('/','-'),build) + if version_format == 'maven': + qualifier = 'SNAPSHOT' if build == 0 else build + return "{}-{}-{}".format(next_version,branch.replace('/','-'),qualifier) if dot: branch = branch.replace('/','.') return branch