def test_finish_release_with_default_default_annotated_tag_message( temp_git_dir, safe_devnull): release_name = "1.0" commit_message = "A commit message" annotation_message = "Version 1.0" config = vc.VCSConfiguration( 'git', {'annotate_tags': True}, global_variables={}, special_variables={'new_version': release_name}, commit_message=commit_message) repo = gr.GitRepo(temp_git_dir, config) repo.pre_start_release() repo.start_release() with open(os.path.join(temp_git_dir, "version.txt"), "w") as f: f.writelines([release_name]) subprocess.check_call(["git", "add", "version.txt"], cwd=temp_git_dir, stdout=safe_devnull, stderr=safe_devnull) repo.finish_release() p = subprocess.Popen(["git", "show", release_name], cwd=temp_git_dir, stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = p.communicate() assert annotation_message in stdout.decode('utf8')
def develop_vcs_configuration(): return vc.VCSConfiguration('git', { 'target_branch': 'develop', }, {}, { 'current_version': 'a', 'new_version': 'b', })
def test_finish_release_with_custom_tag(temp_git_dir, safe_devnull): release_name = "1.0" commit_message = "A commit message" tag = "Version_{}".format(release_name) config = vc.VCSConfiguration( 'git', {'tag': tag}, global_variables={}, special_variables={'new_version': release_name}, commit_message=commit_message) repo = gr.GitRepo(temp_git_dir, config) repo.pre_start_release() repo.start_release() with open(os.path.join(temp_git_dir, "version.txt"), "w") as f: f.writelines([release_name]) subprocess.check_call(["git", "add", "version.txt"], cwd=temp_git_dir, stdout=safe_devnull, stderr=safe_devnull) repo.finish_release() assert tag in repo.get_tags()
def test_release_with_explicit_release_branch(temp_git_dir, safe_devnull): release_name = "1.0" commit_message = "A commit message" config = vc.VCSConfiguration( 'git', {'make_release_branch': True}, global_variables={}, special_variables={'new_version': release_name}, commit_message=commit_message) repo = gr.GitRepo(temp_git_dir, config) repo.pre_start_release() repo.start_release() assert release_name in repo.get_branches() with open(os.path.join(temp_git_dir, "version.txt"), "w") as f: f.writelines([release_name]) subprocess.check_call(["git", "add", "version.txt"], cwd=temp_git_dir, stdout=safe_devnull, stderr=safe_devnull) repo.finish_release() p = subprocess.Popen(["git", "log"], cwd=temp_git_dir, stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = p.communicate() assert commit_message in stdout.decode('utf8') assert release_name in repo.get_tags() assert release_name not in repo.get_branches()
def test_vcs_configuration_from_string_with_include_files( vcs_config_dict_with_include_files, global_variables, special_variables): vcsconf = vc.VCSConfiguration( vcs_config_dict_with_include_files['name'], vcs_config_dict_with_include_files['options'], global_variables, special_variables, vcs_config_dict_with_include_files['commit_message'], include_files=vcs_config_dict_with_include_files['include_files']) assert vcsconf.include_files == ['HISTORY.rst']
def test_finish_release_custom_tag_cannot_be_a_number(temp_hg_dir): release_name = "1.0" commit_message = "A commit message" tag = "12234" config = vc.VCSConfiguration('hg', {'tag': tag}, global_variables={}, special_variables={ 'new_version': release_name}, commit_message=commit_message) with pytest.raises(re.RepositoryConfigurationError): hr.HgRepo(temp_hg_dir, config)
def test_finish_release_custom_tag_cannot_contain_spaces(temp_git_dir): release_name = "1.0" commit_message = "A commit message" tag = "Version {}".format(release_name) config = vc.VCSConfiguration( 'git', {'tag': tag}, global_variables={}, special_variables={'new_version': release_name}, commit_message=commit_message) with pytest.raises(re.RepositoryConfigurationError): gr.GitRepo(temp_git_dir, config)
def ready_to_finish_repo(temp_hg_dir, **kwargs): release_name = "1.0" commit_message = "A commit message" config = vc.VCSConfiguration( 'git', kwargs, global_variables={}, special_variables={'new_version': release_name}, commit_message=commit_message ) repo = hr.HgRepo(temp_hg_dir, config) repo.pre_start_release() repo.start_release() hg_repo_add_file(temp_hg_dir, "version.txt", release_name + "\n") return repo
def test_vcs_configuration_from_string(vcs_configuration_dict, global_variables, special_variables): vcsconf = vc.VCSConfiguration(vcs_configuration_dict['name'], vcs_configuration_dict['options'], global_variables, special_variables, vcs_configuration_dict['commit_message']) expected_options = { 'make_release_branch': False, 'annotate_tags': False, 'annotation_message': '', 'current_version': '1.2.3', 'new_version': '1.3.0' } assert vcsconf.name == 'git' assert vcsconf.commit_message == "Version updated to 1.3.0" assert vcsconf.finish_release is True assert vcsconf.options == expected_options
def test_finish_release_with_annotated_tag(temp_git_dir): release_name = "1.0" commit_message = "A commit message" annotation_message = "An annotation message" config = vc.VCSConfiguration( 'git', {'annotate_tags': True, 'annotation_message': annotation_message}, global_variables={}, special_variables={'new_version': release_name}, commit_message=commit_message ) repo = gr.GitRepo(temp_git_dir, config) repo.pre_start_release() repo.start_release() with open(os.path.join(temp_git_dir, "version.txt"), "w") as f: f.writelines([release_name]) repo.finish_release() p = subprocess.Popen(["git", "log"], cwd=temp_git_dir, stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = p.communicate() assert commit_message in stdout.decode('utf8') p = subprocess.Popen( ["git", "show", release_name], cwd=temp_git_dir, stdout=subprocess.PIPE, stderr=subprocess.PIPE ) stdout, stderr = p.communicate() assert annotation_message in stdout.decode('utf8') assert release_name in repo.get_tags() assert release_name not in repo.get_branches()
def empty_vcs_configuration(): return vc.VCSConfiguration('git', {}, {}, { 'current_version': 'a', 'new_version': 'b' })
def other_branch_vcs_configuration(): return vc.VCSConfiguration( 'hg', {"branch": "other"}, {}, {'current_version': 'a', 'new_version': 'b'} )