Skip to content

Commit 678821a

Browse files
committed
Merge pull request #198 from folti/0.3
GitRunCommand exception can store stdout output too.
2 parents 6404168 + 48f5476 commit 678821a

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

git/cmd.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,10 @@ def execute(self, command,
380380
# END handle debug printing
381381

382382
if with_exceptions and status != 0:
383-
raise GitCommandError(command, status, stderr_value)
383+
if with_extended_output:
384+
raise GitCommandError(command, status, stderr_value, stdout_value)
385+
else:
386+
raise GitCommandError(command, status, stderr_value)
384387

385388
# Allow access to the command's status code
386389
if with_extended_output:

git/exc.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,18 @@ class NoSuchPathError(OSError):
1717

1818
class GitCommandError(Exception):
1919
""" Thrown if execution of the git command fails with non-zero status code. """
20-
def __init__(self, command, status, stderr=None):
20+
def __init__(self, command, status, stderr=None, stdout=None):
2121
self.stderr = stderr
22+
self.stdout = stdout
2223
self.status = status
2324
self.command = command
2425

2526
def __str__(self):
26-
return ("'%s' returned exit status %i: %s" %
27-
(' '.join(str(i) for i in self.command), self.status, self.stderr))
27+
ret = "'%s' returned exit status %i: %s" % \
28+
(' '.join(str(i) for i in self.command), self.status, self.stderr)
29+
if self.stdout is not None:
30+
ret += "\nstdout: %s" % self.stdout
31+
return ret
2832

2933

3034
class CheckoutError( Exception ):

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy