Beispiel #1
0
    def _read_output(self, cmd, *args, **kwds):
        r"""
        Run git and return its output to stdout.

        Same input as :meth:`execute`.

        Raises an error if git returns a non-zero exit code.

        EXAMPLES::

            sage: import os
            sage: from sage.dev.git_interface import GitInterface
            sage: from sage.dev.test.config import DoctestConfig
            sage: from sage.dev.test.user_interface import DoctestUserInterface
            sage: config = DoctestConfig()
            sage: git = GitInterface(config["git"], DoctestUserInterface(config["UI"]))
            sage: os.chdir(config['git']['src'])

            sage: git._read_output('status')
            'On branch master\n\nInitial commit\n\nnothing to commit (create/copy files and use "git add" to track)\n'
            sage: git._read_output('status',foo=True) # --foo is not a valid parameter
            Traceback (most recent call last):
            ...
            GitError: git returned with non-zero exit code (129) for
            "git -c [email protected] -c user.name=doctest status --foo".
            ...
        """
        exit_code, stdout, stderr, cmd = self._run_git(cmd, args, kwds)
        if exit_code:
            raise GitError(exit_code, cmd, stdout, stderr)
        return stdout
Beispiel #2
0
    def _execute_supersilent(self, cmd, *args, **kwds):
        r"""
        Run git and supress its output to stdout and stderr.

        Same input as :meth:`execute`.

        Raises an error if git returns a non-zero exit code.

        EXAMPLES::

            sage: from sage.dev.git_interface import GitInterface
            sage: from sage.dev.test.config import DoctestConfig
            sage: from sage.dev.test.user_interface import DoctestUserInterface
            sage: config = DoctestConfig()
            sage: git = GitInterface(config["git"], DoctestUserInterface(config["UI"]))
            sage: os.chdir(config['git']['src'])

            sage: git._execute_supersilent('status')
            sage: git._execute_supersilent('status',foo=True) # --foo is not a valid parameter
            Traceback (most recent call last):
            ...
            GitError: git returned with non-zero exit code (129) for
            "git -c [email protected] -c user.name=doctest status --foo".
            ...
        """
        exit_code, stdout, stderr, cmd = self._run_git(cmd, args, kwds)
        if exit_code:
            raise GitError(exit_code, cmd, stdout, stderr)
Beispiel #3
0
    def _execute(self, cmd, *args, **kwds):
        r"""
        Run git.

        Raises an exception if git has non-zero exit code.

        INPUT:

        - ``cmd`` -- string. git command run

        - ``args`` -- extra arguments for git

        - ``kwds`` -- extra keywords for git

        EXAMPLES::

            sage: from sage.dev.git_interface import GitInterface
            sage: from sage.dev.test.config import DoctestConfig
            sage: from sage.dev.test.user_interface import DoctestUserInterface
            sage: config = DoctestConfig()
            sage: git = GitInterface(config["git"], DoctestUserInterface(config["UI"]))
            sage: os.chdir(config['git']['src'])

            sage: git._execute('status')
            # On branch master
            #
            # Initial commit
            #
            nothing to commit (create/copy files and use "git add" to track)
            sage: git._execute('status',foo=True) # --foo is not a valid parameter
            Traceback (most recent call last):
            ...
            GitError: git returned with non-zero exit code (129) for
            "git -c [email protected] -c user.name=doctest status --foo".
            output to stderr: error: unknown option `foo'
             usage: git status [options] [--] <filepattern>...
            <BLANKLINE>
                 -v, --verbose         be verbose
                 -s, --short           show status concisely
                 -b, --branch          show branch information
                 --porcelain           machine-readable output
                 -z, --null            terminate entries with NUL
                 -u, --untracked-files[=<mode>]
                                       show untracked files, optional modes: all, normal, no. (Default: all)
                 --ignored             show ignored files
                 --ignore-submodules[=<when>]
                                       ignore changes to submodules, optional when: all, dirty, untracked. (Default: all)
                 --column[=<style>]    list untracked files in columns
            <BLANKLINE>
        """
        exit_code, stdout, stderr, cmd = self._run_git(cmd, args, kwds)
        if exit_code:
            raise GitError(exit_code, cmd, stdout, stderr)
        if stdout:
            print(stdout.strip())
        if stderr:
            print(stderr.strip())
    def _execute(self, cmd, *args, **kwds):
        r"""
        Run git.

        Raises an exception if git has non-zero exit code.

        INPUT:

        - ``cmd`` -- string. git command run

        - ``args`` -- extra arguments for git

        - ``kwds`` -- extra keywords for git

        EXAMPLES::

            sage: from sage.dev.git_interface import GitInterface
            sage: from sage.dev.test.config import DoctestConfig
            sage: from sage.dev.test.user_interface import DoctestUserInterface
            sage: config = DoctestConfig()
            sage: git = GitInterface(config["git"], DoctestUserInterface(config["UI"]))
            sage: os.chdir(config['git']['src'])

            sage: git._execute('status')
            # On branch master
            #
            # Initial commit
            #
            nothing to commit (create/copy files and use "git add" to track)
            sage: git._execute('status',foo=True) # --foo is not a valid parameter
            Traceback (most recent call last):
            ...
            GitError: git returned with non-zero exit code (129) for
            "git -c [email protected] -c user.name=doctest status --foo".
            output to stderr: error: unknown option `foo'
             usage: git status [options] [--] ...
            <BLANKLINE>
                 -v, --verbose         be verbose
                 -s, --short           show status concisely
                 -b, --branch          show branch information
                 --porcelain           machine-readable output
            ...
        """
        exit_code, stdout, stderr, cmd = self._run_git(cmd, args, kwds)
        if exit_code:
            raise GitError(exit_code, cmd, stdout, stderr)
        if stdout:
            print(stdout.strip())
        if stderr:
            print(stderr.strip())
Beispiel #5
0
    def _execute(self, cmd, *args, **kwds):
        r"""
        Run git.

        Raises an exception if git has non-zero exit code.

        INPUT:

        - ``cmd`` -- string. git command run

        - ``args`` -- extra arguments for git

        - ``kwds`` -- extra keywords for git

        EXAMPLES::

            sage: from sage.dev.git_interface import GitInterface
            sage: from sage.dev.test.config import DoctestConfig
            sage: from sage.dev.test.user_interface import DoctestUserInterface
            sage: config = DoctestConfig()
            sage: git = GitInterface(config["git"], DoctestUserInterface(config["UI"]))
            sage: os.chdir(config['git']['src'])

            sage: git._execute('status')
            On branch master
            <BLANKLINE>
            Initial commit
            <BLANKLINE>
            nothing to commit (create/copy files and use "git add" to track)
            sage: git._execute('status',foo=True) # --foo is not a valid parameter
            Traceback (most recent call last):
            ...
            GitError: git returned with non-zero exit code ...
        """
        exit_code, stdout, stderr, cmd = self._run_git(cmd, args, kwds)
        if exit_code:
            raise GitError(exit_code, cmd, stdout, stderr)
        if stdout:
            print(stdout.strip())
        if stderr:
            print(stderr.strip())
    def _execute_silent(self, cmd, *args, **kwds):
        r"""
        Run git and supress its output to stdout.

        Same input as :meth:`execute`.

        Raises an error if git returns a non-zero exit code.

        EXAMPLES::

            sage: from sage.dev.git_interface import GitInterface
            sage: from sage.dev.test.config import DoctestConfig
            sage: from sage.dev.test.user_interface import DoctestUserInterface
            sage: config = DoctestConfig()
            sage: git = GitInterface(config["git"], DoctestUserInterface(config["UI"]))
            sage: os.chdir(config['git']['src'])

            sage: git._execute_silent('status')
            sage: git._execute_silent('status',foo=True) # --foo is not a valid parameter
            Traceback (most recent call last):
            ...
            GitError: git returned with non-zero exit code (129) for
            "git -c [email protected] -c user.name=doctest status --foo".
            output to stderr: error: unknown option `foo'
             usage: git status [options] [--] ...
            <BLANKLINE>
                 -v, --verbose         be verbose
                 -s, --short           show status concisely
                 -b, --branch          show branch information
                 --porcelain           machine-readable output
            ...
        """
        exit_code, stdout, stderr, cmd = self._run_git(cmd, args, kwds)
        if exit_code:
            raise GitError(exit_code, cmd, stdout, stderr)
        if stderr:
            print(stderr.strip())