def test_uses_current_and_write_for_actual_operation(p_write, p_current): p_current.return_value = '0.9.5' versioning.bump() p_current.assert_called_once_with() p_write.assert_called_once_with('0.9.6')
def test_properly_bumps_the_version(p_write, p_current, version, component, expected): p_current.return_value = version versioning.bump(component) p_current.assert_called_once_with() p_write.assert_called_once_with(expected)
def start(component: str, exact: str): """ Create a new release branch. Args: component (str): Version component to bump when creating the release. Can be *major*, *minor* or *patch*. exact (str): The exact version to set for the release. Overrides the component argument. This allows to re-release a version if something went wrong with the release upload. """ version_files = versioning.get_version_files() develop = conf.get('git.devel_branch', 'develop') common.assert_on_branch(develop) with conf.within_proj_dir(): out = shell.run('git status --porcelain', capture=True).stdout lines = out.split(os.linesep) has_changes = any(not line.startswith('??') for line in lines if line.strip()) if has_changes: log.info("Cannot release: there are uncommitted changes") exit(1) old_ver, new_ver = versioning.bump(component, exact) log.info("Bumping package version") log.info(" old version: <35>{}".format(old_ver)) log.info(" new version: <35>{}".format(new_ver)) with conf.within_proj_dir(): branch = 'release/' + new_ver hooks.register.call('pre-release-start', branch, old_ver, new_ver) common.git_checkout(branch, create=True) log.info("Creating commit for the release") shell.run('git add {files} && git commit -m "{msg}"'.format( files=' '.join(f'"{v.path}"' for v in version_files), msg="Releasing v{}".format(new_ver))) hooks.register.call('post-release-start', branch, old_ver, new_ver)
def bump_version(component: str = 'patch', exact: Optional[str] = None): """ Bump current project version without committing anything. No tags are created either. Examples: \b $ peltak version bump patch # Bump patch version component $ peltak version bump minor # Bump minor version component $ peltak version bump major # Bump major version component $ peltak version bump release # same as version bump patch $ peltak version bump --exact=1.2.1 # Set project version to 1.2.1 """ from peltak.core import log from peltak.core import versioning old_ver, new_ver = versioning.bump(component, exact) log.info("Project version bumped") log.info(" old version: <35>{}".format(old_ver)) log.info(" new version: <35>{}".format(new_ver))
def test_raises_ValueError_if_invalid_component_is_passed(): with pytest.raises(ValueError): versioning.bump('invalid_component')
def test_raises_ValueError_if_current_version_is_invalid(p_current): p_current.return_value = 'invalid_ver' with pytest.raises(ValueError): versioning.bump()
def test_raises_ValueError_if_invalid_version_is_given(): with pytest.raises(ValueError): versioning.bump(exact='invalid_ver')