only dry run version if the branch is of a version type

This commit is contained in:
Derek DeJonghe 2020-06-15 17:48:27 -04:00
parent 0265f52eb3
commit fbdc7af4df
2 changed files with 13 additions and 12 deletions

View File

@ -26,15 +26,16 @@ def get_version(build=0,version_format=None,dot=False):
logger.debug("merged branch is: {}".format(semver.merged_branch))
version_type = semver.get_version_type()
logger.debug("version type is: {}".format(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.stdout.read().decode('utf-8').rstrip()
next_version = re.search("new_version=([0-9]*.[0-9]*.[0-9]*)", bump_output).group(1)
if 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.stdout.read().decode('utf-8').rstrip()
next_version = re.search("new_version=([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 == '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

View File

@ -63,14 +63,14 @@ class TestGetVersion(unittest.TestCase):
self.assertEqual(branch, "test/branch")
def test_branch_npm_pre_release(self):
create_git_environment()
subprocess.call(['git', 'checkout', '-b', 'test/branch'])
subprocess.call(['git', 'checkout', '-b', 'patch/branch'])
branch = get_version.get_version(version_format='npm')
self.assertEqual(branch, "0.0.0-test-branch.0")
self.assertEqual(branch, "0.0.0-patch-branch.0")
def test_branch_maven_pre_release(self):
create_git_environment()
subprocess.call(['git', 'checkout', '-b', 'test/branch'])
subprocess.call(['git', 'checkout', '-b', 'minor/branch'])
branch = get_version.get_version(version_format='npm')
self.assertEqual(branch, "0.0.0-test-branch-SNAPSHOT")
self.assertEqual(branch, "0.0.0-minor-branch-SNAPSHOT")
def test_get_version_run(self):
create_git_environment()
val = subprocess.Popen(['python', '../get_version.py', '-d'], stdout=subprocess.PIPE,