From 5077fc7e4031e53f730676df4d8df5165b1d36cc Mon Sep 17 00:00:00 2001 From: Barry Scott Date: Sun, 29 May 2016 13:34:35 +0100 Subject: Return all the stderr messge after an error is detected for pull() --- git/remote.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'git/remote.py') diff --git a/git/remote.py b/git/remote.py index 30e32ae3..f23f50a2 100644 --- a/git/remote.py +++ b/git/remote.py @@ -570,11 +570,16 @@ class Remote(LazyMixin, Iterable): progress_handler = progress.new_message_handler() + error_message = None + stderr_text = None + for line in proc.stderr: line = force_text(line) for pline in progress_handler(line): if line.startswith('fatal:') or line.startswith('error:'): - raise GitCommandError(("Error when fetching: %s" % line,), 2) + error_message = "Error when fetching: %s" % (line,) + break + # END handle special messages for cmd in cmds: if len(line) > 1 and line[0] == ' ' and line[1] == cmd: @@ -582,9 +587,19 @@ class Remote(LazyMixin, Iterable): continue # end find command code # end for each comand code we know + + if error_message is not None: + break # end for each line progress didn't handle + + if error_message is not None: + stderr_text = proc.stderr.read() + # end - finalize_process(proc) + finalize_process(proc, stderr=stderr_text) + + if error_message is not None: + raise GitCommandError( error_message, 2, stderr=stderr_text ) # read head information fp = open(join(self.repo.git_dir, 'FETCH_HEAD'), 'rb') -- cgit v1.2.1 From 78f3f38d18fc88fd639af8a6c1ef757d2ffe51d6 Mon Sep 17 00:00:00 2001 From: Barry Scott Date: Sun, 29 May 2016 13:59:53 +0100 Subject: Return stderr lines from a pull() call that fails --- git/remote.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'git/remote.py') 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 -- cgit v1.2.1 From 46201b346fec29f9cb740728a3c20266094d58b2 Mon Sep 17 00:00:00 2001 From: Barry Scott Date: Mon, 30 May 2016 15:05:32 +0100 Subject: Fix flake8 complaints --- git/remote.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'git/remote.py') diff --git a/git/remote.py b/git/remote.py index 1ef62409..ba51fe92 100644 --- a/git/remote.py +++ b/git/remote.py @@ -599,7 +599,7 @@ class Remote(LazyMixin, Iterable): finalize_process(proc, stderr=stderr_text) if error_message is not None: - raise GitCommandError( error_message, 2, stderr=stderr_text ) + raise GitCommandError(error_message, 2, stderr=stderr_text) # read head information fp = open(join(self.repo.git_dir, 'FETCH_HEAD'), 'rb') @@ -648,7 +648,7 @@ class Remote(LazyMixin, Iterable): 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() ) + raise GitCommandError(err.command, err.status, progress.get_stderr()) except Exception: if len(output) == 0: -- cgit v1.2.1