def deploy(self, *args, **kwargs): repo = kwargs.get('repo') if repo: subdomain = self._get_subdomain() self.webreview.name = subdomain try: self.webreview.commit = utils.create_commit_message(repo) except ValueError: raise ValueError( 'Cannot deploy to WebReview from a Git repository without a HEAD.' ' Commit first then deploy to WebReview.') result = super(WebReviewDestination, self).deploy(*args, **kwargs) if self.success: finalize_response = self.webreview.finalize() if 'fileset' in finalize_response: url = finalize_response['fileset']['url'] # Append the homepage path to the staging link. result = urlparse.urlparse(url) if not result.path and self.pod and self.pod.get_home_doc(): home_doc = self.pod.get_home_doc() url = url.rstrip('/') + home_doc.url.path logging.info('Staged: %s', url) return result
def test_commit_message_ref_error(self, _): """Continues without head ref.""" ref = self._mock_ref(name_side_effect=TypeError('Bang!')) mock_repo = self._mock_repo(ref=ref) utils.create_commit_message(mock_repo)
def test_commit_message_error(self, _): """Fails without git head.""" head = self._mock_head(commit_side_effect=ValueError('Bang!')) mock_repo = self._mock_repo(head=head) with self.assertRaises(utils.NoGitHeadError): utils.create_commit_message(mock_repo)
def test_commit_message(self, _): """Create normal commit message.""" mock_repo = self._mock_repo() message = utils.create_commit_message(mock_repo) self.assertEqual(message.sha, 'sha')