only dry run version if the branch is of a version type
This commit is contained in:
parent
0265f52eb3
commit
fbdc7af4df
@ -26,15 +26,16 @@ def get_version(build=0,version_format=None,dot=False):
|
|||||||
logger.debug("merged branch is: {}".format(semver.merged_branch))
|
logger.debug("merged branch is: {}".format(semver.merged_branch))
|
||||||
version_type = semver.get_version_type()
|
version_type = semver.get_version_type()
|
||||||
logger.debug("version type is: {}".format(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='.')
|
if version_type:
|
||||||
bump_output = p.stdout.read().decode('utf-8').rstrip()
|
p = subprocess.Popen(['bumpversion', '--dry-run', '--verbose', '--current-version', get_tag_version(), version_type], stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd='.')
|
||||||
next_version = re.search("new_version=([0-9]*.[0-9]*.[0-9]*)", bump_output).group(1)
|
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':
|
if version_format == 'npm':
|
||||||
return "{}-{}.{}".format(next_version,branch.replace('/','-'),build)
|
return "{}-{}.{}".format(next_version,branch.replace('/','-'),build)
|
||||||
if version_format == 'maven':
|
if version_format == 'maven':
|
||||||
qualifier = 'SNAPSHOT' if build == 0 else build
|
qualifier = 'SNAPSHOT' if build == 0 else build
|
||||||
return "{}-{}-{}".format(next_version,branch.replace('/','-'),qualifier)
|
return "{}-{}-{}".format(next_version,branch.replace('/','-'),qualifier)
|
||||||
if dot:
|
if dot:
|
||||||
branch = branch.replace('/','.')
|
branch = branch.replace('/','.')
|
||||||
return branch
|
return branch
|
||||||
|
@ -63,14 +63,14 @@ class TestGetVersion(unittest.TestCase):
|
|||||||
self.assertEqual(branch, "test/branch")
|
self.assertEqual(branch, "test/branch")
|
||||||
def test_branch_npm_pre_release(self):
|
def test_branch_npm_pre_release(self):
|
||||||
create_git_environment()
|
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')
|
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):
|
def test_branch_maven_pre_release(self):
|
||||||
create_git_environment()
|
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')
|
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):
|
def test_get_version_run(self):
|
||||||
create_git_environment()
|
create_git_environment()
|
||||||
val = subprocess.Popen(['python', '../get_version.py', '-d'], stdout=subprocess.PIPE,
|
val = subprocess.Popen(['python', '../get_version.py', '-d'], stdout=subprocess.PIPE,
|
||||||
|
Loading…
Reference in New Issue
Block a user