def bump(increment, init): """Increases git tag containing semantic version""" if init: current_version = '0.0.0' else: # Get all version-formatted tags, but use the latest current_version = check_output( r'git tag -l *.*.* --contains $(git rev-list --tags --max-count=1)', shell=True ).decode().rstrip().split('\n')[-1] new_version = bumped_version(current_version, increment) print(f'Bumping "{increment}" version: {current_version} ==> {new_version}') if utils.confirm('Do you want to tag the current commit with that version?'): check_output(f'git tag -a {new_version} -m "Version {new_version}"', shell=True) print('Latest tags:') print(check_output('git tag --sort=-version:refname -n1 | head -n5', shell=True).decode().rstrip()) else: print('Aborted. No tags were added!') return if utils.confirm('Do you want to push this tag?'): check_call('git push --tags', shell=True, stderr=STDOUT)
def release_edge(): """Create develop -> edge PRs for all managed repositories""" prepare() for repo in REPOS: if not utils.confirm(f'Do you want to create a develop -> edge PR for {repo}?'): continue with suppress(CalledProcessError): check_call( 'hub pull-request -b edge -h develop -m "edge release"', shell=True, cwd=f'{WORKDIR}/{repo}')
def test_user_yes_no_query(mocked_ext, user_input, expected): mocked_ext['input'].side_effect = user_input assert utils.confirm('Are you sure?') == expected
def prepare(): create_repos() if not which('hub') and utils.confirm('hub cli not found - do you want to install it?'): install_hub()