Beispiel #1
0
    def amend_commit_description(self, message, revisions):
        """Update a commit message to the given string.

        Args:
            message (unicode):
                The commit message to use when amending the commit.

            revisions (dict):
                A dictionary of revisions, as returned by
                :py:meth:`parse_revision_spec`.

        Raises:
            rbtools.clients.errors.AmendError:
                The requested revision tip was not the most recent commit.
                Unless rewriting the entire series of commits, git can only
                amend the latest commit on the branch.
        """
        if revisions and revisions['tip']:
            commit_ids = self._execute(
                [self.git, 'rev-parse', 'HEAD', revisions['tip']],
                split_lines=True)
            head_id = commit_ids[0].strip()
            revision_id = commit_ids[1].strip()

            if head_id != revision_id:
                raise AmendError('Commit "%s" is not the latest commit, '
                                 'and thus cannot be modified' % revision_id)

        self._execute([self.git, 'commit', '--amend', '-m', message])
Beispiel #2
0
    def amend_commit_description(self, message, revisions):
        """Update a commit message to the given string.

        Since git can amend only the most recent commit, an AmendError will be
        raised if revisions points to a commit other than the the most recent
        commit.
        """
        if revisions and revisions['tip']:
            commit_ids = execute([self.git, 'rev-parse', 'HEAD',
                                  revisions['tip']], split_lines=True)
            head_id = commit_ids[0].strip()
            revision_id = commit_ids[1].strip()

            if head_id != revision_id:
                raise AmendError('Commit "%s" is not the latest commit, '
                                 'and thus cannot be modified' % revision_id)

        execute([self.git, 'commit', '--amend', '-m', message])