def execute(self, diffs): if not self.pull_request.maintainer_can_modify: msg = ('Cannot apply automatic fixing, ' 'as this pull request cannot be ' 'modified by maintainers.') raise WorkflowError(msg) if self.pull_request.from_private_fork: msg = ('Cannot apply automatic fixing, ' 'as this pull request comes from a private fork.') raise WorkflowError(msg) git.create_branch(self.path, 'stylefixes') git.checkout(self.path, 'stylefixes') for diff in diffs: git.apply_cached(self.path, diff.as_diff()) author = u'{} <{}>'.format(self.author_name, self.author_email) remote_branch = self.pull_request.head_branch git.commit(self.path, author, 'Fixing style errors.') try: git.push(self.path, 'origin', u'stylefixes:{}'.format(remote_branch)) except IOError as err: message = six.text_type(err) log.debug(message) if '(permission denied)' in message: raise WorkflowError('Could not push fix commit because permission was denied') if '[remote rejected]' in message: raise WorkflowError('Could not push fix commit because it was not a fast-forward') raise err
def execute(self, diffs): if not self.pull_request.maintainer_can_modify: msg = ('Cannot apply automatic fixing, ' 'as this pull request cannot be ' 'modified by maintainers.') raise WorkflowError(msg) if self.pull_request.from_private_fork: msg = ('Cannot apply automatic fixing, ' 'as this pull request comes from a private fork.') raise WorkflowError(msg) git.create_branch(self.path, 'stylefixes') git.checkout(self.path, 'stylefixes') for diff in diffs: git.apply_cached(self.path, diff.as_diff()) author = u'{} <{}>'.format(self.author_name, self.author_email) remote_branch = self.pull_request.head_branch git.commit(self.path, author, 'Fixing style errors.') try: git.push(self.path, 'origin', u'stylefixes:{}'.format(remote_branch)) except IOError as err: message = six.text_type(err) log.debug(message) if '(permission denied)' in message: raise WorkflowError( 'Could not push fix commit because permission was denied') if '[remote rejected]' in message: raise WorkflowError( 'Could not push fix commit because it was not a fast-forward' ) raise err
def execute(self, diffs): git.create_branch(self.path, 'stylefixes') git.checkout(self.path, 'stylefixes') for diff in diffs: git.apply_cached(self.path, diff.as_diff()) git.commit(self.path, self.author, 'Fixing style errors.') git.push(self.path, 'origin', 'stylefixes:' + self.remote_branch)
def execute(self, diffs): if not self.pull_request.maintainer_can_modify: msg = ('Cannot apply automatic fixing, ' 'as this pull request cannot be ' 'modified by maintainers.') raise WorkflowError(msg) git.create_branch(self.path, 'stylefixes') git.checkout(self.path, 'stylefixes') for diff in diffs: git.apply_cached(self.path, diff.as_diff()) author = u'{} <{}>'.format(self.author_name, self.author_email) remote_branch = self.pull_request.head_branch git.commit(self.path, author, 'Fixing style errors.') git.push(self.path, 'origin', 'stylefixes:' + remote_branch)
def test_push__fails(): try: git.push(clone_path, 'origin', 'master') except IOError as e: assert_in('origin:master', str(e))
def test_push__fails(self): try: git.push(clone_path, 'origin', 'master') except IOError as e: self.assertIn('origin:master', str(e))