Example #1
0
    def create_commit(self,
                      message,
                      author,
                      run_editor,
                      files=[],
                      all_files=False):
        """Commits the given modified files.

        This is expected to be called after applying a patch. This commits the
        patch using information from the review request, opening the commit
        message in $EDITOR to allow the user to update it.
        """
        if run_editor:
            modified_message = edit_text(message)
        else:
            modified_message = message

        if all_files:
            execute(['git', 'add', '--all', ':/'])
        elif files:
            execute(['git', 'add'] + files)

        execute([
            'git', 'commit', '-m', modified_message,
            '--author="%s <%s>"' % (author.fullname, author.email)
        ])
Example #2
0
    def create_commit(self,
                      message,
                      author,
                      run_editor,
                      files=[],
                      all_files=False):
        """Commits the given modified files.

        This is expected to be called after applying a patch. This commits the
        patch using information from the review request, opening the commit
        message in $EDITOR to allow the user to update it.
        """
        if run_editor:
            modified_message = edit_text(message)
        else:
            modified_message = message

        if all_files:
            execute(['git', 'add', '--all', ':/'])
        elif files:
            execute(['git', 'add'] + files)

        execute([
            'git', 'commit', '-m', modified_message,
            '--author="%s <%s>"' % (author.fullname, author.email)
        ])
Example #3
0
File: git.py Project: dbuzz/rbtools
    def create_commit(self, message, author, files=[], all_files=False):
        modified_message = edit_text(message)

        if all_files:
            execute(['git', 'add', '--all', ':/'])
        elif files:
            execute(['git', 'add'] + files)

        execute(['git', 'commit', '-m', modified_message,
                 '--author="%s <%s>"' % (author.fullname, author.email)])
Example #4
0
    def test_edit_text_with_filename(self):
        """Testing edit_text with custom filename"""
        self.spy_on(subprocess.call)

        result = edit_text('Test content', filename='my-custom-filename')

        self.assertEqual(result, 'TEST CONTENT')
        self.assertEqual(
            os.path.basename(subprocess.call.last_call.args[0][-1]),
            'my-custom-filename')
Example #5
0
    def create_commit(self, message, author, files=[], all_files=False):
        modified_message = edit_text(message)

        if all_files:
            execute(['git', 'add', '--all', ':/'])
        elif files:
            execute(['git', 'add'] + files)

        execute(['git', 'commit', '-m', modified_message,
                 '--author="%s <%s>"' % (author.fullname, author.email)])
Example #6
0
    def create_commit(self, message, author, files=[], all_files=False):
        """Commits the given modified files.

        This is expected to be called after applying a patch. This commits the
        patch using information from the review request, opening the commit
        message in $EDITOR to allow the user to update it.
        """
        modified_message = edit_text(message)

        hg_command = ['hg', 'commit', '-m', modified_message,
                      '-u %s <%s>' % (author.fullname, author.email)]

        execute(hg_command + files)
Example #7
0
    def create_commit(self,
                      message,
                      author,
                      run_editor,
                      files=[],
                      all_files=False):
        """Commit the given modified files.

        This is expected to be called after applying a patch. This commits the
        patch using information from the review request, opening the commit
        message in $EDITOR to allow the user to update it.

        Args:
            message (unicode):
                The commit message to use.

            author (object):
                The author of the commit. This is expected to have ``fullname``
                and ``email`` attributes.

            run_editor (bool):
                Whether to run the user's editor on the commmit message before
                committing.

            files (list of unicode, optional):
                The list of filenames to commit.

            all_files (bool, optional):
                Whether to commit all changed files, ignoring the ``files``
                argument.
        """
        if run_editor:
            modified_message = edit_text(message)
        else:
            modified_message = message

        hg_command = ['hg', 'commit', '-m', modified_message]

        try:
            hg_command.append('-u %s <%s>' % (author.fullname, author.email))
        except AttributeError:
            # Users who have marked their profile as private won't include the
            # fullname or email fields in the API payload. Just commit as the
            # user running RBTools.
            logging.warning('The author has marked their Review Board profile '
                            'information as private. Committing without '
                            'author attribution.')

        execute(hg_command + files)
Example #8
0
    def create_commit(self, message, author, run_editor,
                      files=[], all_files=False):
        """Commit the given modified files.

        This is expected to be called after applying a patch. This commits the
        patch using information from the review request, opening the commit
        message in $EDITOR to allow the user to update it.

        Args:
            message (unicode):
                The commit message to use.

            author (object):
                The author of the commit. This is expected to have ``fullname``
                and ``email`` attributes.

            run_editor (bool):
                Whether to run the user's editor on the commmit message before
                committing.

            files (list of unicode, optional):
                The list of filenames to commit.

            all_files (bool, optional):
                Whether to commit all changed files, ignoring the ``files``
                argument.
        """
        if run_editor:
            modified_message = edit_text(message)
        else:
            modified_message = message

        hg_command = ['hg', 'commit', '-m', modified_message]

        try:
            hg_command.append('-u %s <%s>' % (author.fullname, author.email))
        except AttributeError:
            # Users who have marked their profile as private won't include the
            # fullname or email fields in the API payload. Just commit as the
            # user running RBTools.
            logging.warning('The author has marked their Review Board profile '
                            'information as private. Committing without '
                            'author attribution.')

        execute(hg_command + files)
Example #9
0
    def create_commit(self,
                      message,
                      author,
                      run_editor,
                      files=[],
                      all_files=False):
        """Commit the given modified files.

        This is expected to be called after applying a patch. This commits the
        patch using information from the review request, opening the commit
        message in :envvar:`$EDITOR` to allow the user to update it.

        Args:
            message (unicode):
                The commit message to use.

            author (object):
                The author of the commit. This is expected to have ``fullname``
                and ``email`` attributes.

            run_editor (bool):
                Whether to run the user's editor on the commmit message before
                committing.

            files (list of unicode, optional):
                The list of filenames to commit.

            all_files (bool, optional):
                Whether to commit all changed files, ignoring the ``files``
                argument.
        """
        if run_editor:
            modified_message = edit_text(message)
        else:
            modified_message = message

        if all_files:
            self._execute(['git', 'add', '--all', ':/'])
        elif files:
            self._execute(['git', 'add'] + files)

        self._execute([
            'git', 'commit', '-m', modified_message,
            '--author="%s <%s>"' % (author.fullname, author.email)
        ])
Example #10
0
    def create_commit(self, message, author, run_editor,
                      files=[], all_files=False):
        """Commit the given modified files.

        This is expected to be called after applying a patch. This commits the
        patch using information from the review request, opening the commit
        message in $EDITOR to allow the user to update it.

        Args:
            message (unicode):
                The commit message to use.

            author (object):
                The author of the commit. This is expected to have ``fullname``
                and ``email`` attributes.

            run_editor (bool):
                Whether to run the user's editor on the commmit message before
                committing.

            files (list of unicode, optional):
                The list of filenames to commit.

            all_files (bool, optional):
                Whether to commit all changed files, ignoring the ``files``
                argument.
        """
        if run_editor:
            modified_message = edit_text(message)
        else:
            modified_message = message

        hg_command = ['hg', 'commit', '-m', modified_message,
                      '-u %s <%s>' % (author.fullname, author.email)]

        execute(hg_command + files)
Example #11
0
    def test_edit_text(self):
        """Testing edit_text"""
        result = edit_text('Test content')

        self.assertEqual(result, 'TEST CONTENT')
Example #12
0
 def create_commmit(self, message, author):
     modified_message = edit_text(message)
     execute(['git', 'add', '--all', ':/'])
     execute(['git', 'commit', '-m', modified_message,
              '--author="%s <%s>"' % (author.fullname, author.email)])