Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add stdout option to GitCommandError #91

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion git/cmd.py
Original file line number Diff line number Diff line change
@@ -378,7 +378,7 @@ def execute(self, command,
# END handle debug printing

if with_exceptions and status != 0:
raise GitCommandError(command, status, stderr_value)
raise GitCommandError(command, status, stderr_value, stdout_value)

# Allow access to the command's status code
if with_extended_output:
5 changes: 3 additions & 2 deletions git/exc.py
Original file line number Diff line number Diff line change
@@ -17,14 +17,15 @@ class NoSuchPathError(OSError):

class GitCommandError(Exception):
""" Thrown if execution of the git command fails with non-zero status code. """
def __init__(self, command, status, stderr=None):
def __init__(self, command, status, stderr=None, stdout=None):
self.stderr = stderr
self.stdout = stdout
self.status = status
self.command = command

def __str__(self):
return ("'%s' returned exit status %i: %s" %
(' '.join(str(i) for i in self.command), self.status, self.stderr))
(' '.join(str(i) for i in self.command), self.status, self.stderr, self.stdout))


class CheckoutError( Exception ):