Having execute() use a different directory is an important piece
of API information so I added more documentation about it and
renamed the flag to just "keep_cwd" since that's shorter and simpler.
Signed-off-by: David Aguilar <davvid@gmail.com>
def execute(self, command,
istream=None,
def execute(self, command,
istream=None,
with_status=False,
with_stderr=False,
with_exceptions=False,
with_raw_output=False,
with_status=False,
with_stderr=False,
with_exceptions=False,
with_raw_output=False,
):
"""
Handles executing the command on the shell and consumes and returns
):
"""
Handles executing the command on the shell and consumes and returns
``istream``
Standard input filehandle passed to subprocess.Popen.
``istream``
Standard input filehandle passed to subprocess.Popen.
+ ``keep_cwd``
+ Whether to use the current working directory from os.getcwd().
+ GitPython uses get_work_tree() as its working directory by
+ default and get_git_dir() for bare repositories.
+
``with_status``
Whether to return a (status, str) tuple.
``with_status``
Whether to return a (status, str) tuple.
``with_raw_output``
Whether to avoid stripping off trailing whitespace.
``with_raw_output``
Whether to avoid stripping off trailing whitespace.
- ``with_keep_cwd``
- Whether to use the current working directory from os.getcwd().
-
Returns
str(output) # with_status = False (Default)
tuple(int(status), str(output)) # with_status = True
Returns
str(output) # with_status = False (Default)
tuple(int(status), str(output)) # with_status = True
stderr = subprocess.PIPE
# Allow the user to have the command executed in their working dir.
stderr = subprocess.PIPE
# Allow the user to have the command executed in their working dir.
cwd = os.getcwd()
else:
cwd=self._cwd
cwd = os.getcwd()
else:
cwd=self._cwd
# Handle optional arguments prior to calling transform_kwargs
# otherwise these'll end up in args, which is bad.
istream = kwargs.pop("istream", None)
# Handle optional arguments prior to calling transform_kwargs
# otherwise these'll end up in args, which is bad.
istream = kwargs.pop("istream", None)
+ keep_cwd = kwargs.pop("keep_cwd", None)
with_status = kwargs.pop("with_status", None)
with_stderr = kwargs.pop("with_stderr", None)
with_exceptions = kwargs.pop("with_exceptions", None)
with_raw_output = kwargs.pop("with_raw_output", None)
with_status = kwargs.pop("with_status", None)
with_stderr = kwargs.pop("with_stderr", None)
with_exceptions = kwargs.pop("with_exceptions", None)
with_raw_output = kwargs.pop("with_raw_output", None)
- with_keep_cwd = kwargs.pop("with_keep_cwd", None)
# Prepare the argument list
opt_args = self.transform_kwargs(**kwargs)
# Prepare the argument list
opt_args = self.transform_kwargs(**kwargs)
return self.execute(call,
istream = istream,
return self.execute(call,
istream = istream,
with_status = with_status,
with_stderr = with_stderr,
with_exceptions = with_exceptions,
with_raw_output = with_raw_output,
with_status = with_status,
with_stderr = with_stderr,
with_exceptions = with_exceptions,
with_raw_output = with_raw_output,
- with_keep_cwd = with_keep_cwd,