def make_rpc_report(repo_dir, old_commit, new_commit, args): """Create initial RST report header for OpenStack-Ansible.""" rpc_repo_url = "https://github.com/rcbops/rpc-openstack" osa_differ.update_repo(repo_dir, rpc_repo_url, args.update) # Are these commits valid? osa_differ.validate_commits(repo_dir, [old_commit, new_commit]) # Do we have a valid commit range? osa_differ.validate_commit_range(repo_dir, old_commit, new_commit) # Get the commits in the range commits = osa_differ.get_commits(repo_dir, old_commit, new_commit) # Start off our report with a header and our OpenStack-Ansible commits. template_vars = { 'args': args, 'repo': 'rpc-openstack', 'commits': commits, 'commit_base_url': osa_differ.get_commit_url(rpc_repo_url), 'old_sha': old_commit, 'new_sha': new_commit } return render_template('offline-header.j2', template_vars)
def test_commit_invalid(self, tmpdir): """Verify that we can find valid commits.""" p = tmpdir.mkdir('test') path = str(p) repo = Repo.init(path) file = p / 'test.txt' file.write_text(u'Testing', encoding='utf-8') repo.index.add(['test.txt']) repo.index.commit('Testing') with raises(Exception): osa_differ.validate_commits(path, ['HEAD~1'])
def validate_rpc_sha(repo_dir, commit): """Validate/update a SHA given for the rpc-openstack repo.""" # Is the commit valid? Just in case the commit is a # PR ref, we try both the ref given and the ref prepended # with the remote 'origin'. try: osa_differ.validate_commits(repo_dir, [commit]) except exceptions.InvalidCommitException: log.debug("The reference {c} cannot be found. Prepending " "origin remote and retrying.".format(c=commit)) commit = 'origin/' + commit osa_differ.validate_commits(repo_dir, [commit]) return commit
def test_commit_valid(self, tmpdir): """Verify that we can find valid commits.""" p = tmpdir.mkdir('test') path = str(p) repo = Repo.init(path) file = p / 'test.txt' file.write_text(u'Testing', encoding='utf-8') repo.index.add(['test.txt']) repo.index.commit('Testing') result = osa_differ.validate_commits(path, ['HEAD']) assert result
def make_rpc_report(repo_dir, old_commit, new_commit, args): """Create initial RST report header for OpenStack-Ansible.""" rpc_repo_url = args.rpc_repo_url osa_differ.update_repo(repo_dir, rpc_repo_url, args.update) # Are these commits valid? osa_differ.validate_commits(repo_dir, [old_commit, new_commit]) # Do we have a valid commit range? # NOTE: # An exception is thrown by osa_differ if these two commits # are the the same, but it is sometimes necessary to compare # two RPC tags that have the same OSA SHA. For example, # comparing two tags that only have differences between the # two RPCO commit, but no differences between the OSA SHAs # that correspond to those two commits. # To handle this case, the exception will be caught and flow # of execution will continue normally. try: osa_differ.validate_commit_range(repo_dir, old_commit, new_commit) except exceptions.InvalidCommitRangeException: pass # Get the commits in the range commits = osa_differ.get_commits(repo_dir, old_commit, new_commit) # Start off our report with a header and our OpenStack-Ansible commits. template_vars = { 'args': args, 'repo': 'rpc-openstack', 'commits': commits, 'commit_base_url': osa_differ.get_commit_url(rpc_repo_url), 'old_sha': old_commit, 'new_sha': new_commit } return render_template('offline-header.j2', template_vars)