summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBarry Scott <barry@barrys-emacs.org>2016-05-29 13:59:53 +0100
committerBarry Scott <barry@barrys-emacs.org>2016-05-29 13:59:53 +0100
commit78f3f38d18fc88fd639af8a6c1ef757d2ffe51d6 (patch)
tree9098ad5f1beebb4eef62944e7b1458bdb4c840e0
parent5077fc7e4031e53f730676df4d8df5165b1d36cc (diff)
downloadgitpython-78f3f38d18fc88fd639af8a6c1ef757d2ffe51d6.tar.gz
Return stderr lines from a pull() call that fails
-rw-r--r--git/remote.py4
-rw-r--r--git/util.py10
2 files changed, 13 insertions, 1 deletions
diff --git a/git/remote.py b/git/remote.py
index f23f50a2..1ef62409 100644
--- a/git/remote.py
+++ b/git/remote.py
@@ -646,6 +646,10 @@ class Remote(LazyMixin, Iterable):
try:
handle_process_output(proc, stdout_handler, progress_handler, finalize_process)
+ except GitCommandError as err:
+ # convert any error from wait() into the same error with stdout lines
+ raise GitCommandError( err.command, err.status, progress.get_stderr() )
+
except Exception:
if len(output) == 0:
raise
diff --git a/git/util.py b/git/util.py
index 5ed014fc..f185156c 100644
--- a/git/util.py
+++ b/git/util.py
@@ -173,13 +173,17 @@ class RemoteProgress(object):
DONE_TOKEN = 'done.'
TOKEN_SEPARATOR = ', '
- __slots__ = ("_cur_line", "_seen_ops")
+ __slots__ = ("_cur_line", "_seen_ops", "_error_lines")
re_op_absolute = re.compile(r"(remote: )?([\w\s]+):\s+()(\d+)()(.*)")
re_op_relative = re.compile(r"(remote: )?([\w\s]+):\s+(\d+)% \((\d+)/(\d+)\)(.*)")
def __init__(self):
self._seen_ops = list()
self._cur_line = None
+ self._error_lines = []
+
+ def get_stderr(self):
+ return '\n'.join(self._error_lines)
def _parse_progress_line(self, line):
"""Parse progress information from the given line as retrieved by git-push
@@ -190,6 +194,10 @@ class RemoteProgress(object):
# Counting objects: 4, done.
# Compressing objects: 50% (1/2) \rCompressing objects: 100% (2/2) \rCompressing objects: 100% (2/2), done.
self._cur_line = line
+ if len(self._error_lines) > 0 or self._cur_line.startswith( ('error:', 'fatal:') ):
+ self._error_lines.append( self._cur_line )
+ return []
+
sub_lines = line.split('\r')
failed_lines = list()
for sline in sub_lines: