diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2016-06-13 09:10:01 +0200 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2016-06-13 09:10:01 +0200 |
commit | da86442f6a7bf1263fb5aafdaf904ed2f7db839f (patch) | |
tree | ea368b8973aaceace5f2ef51188005d95be4bc9d /git/remote.py | |
parent | ec830a25d39d4eb842ae016095ba257428772294 (diff) | |
parent | 6891caf73735ea465c909de8dc13129cc98c47f7 (diff) | |
download | gitpython-da86442f6a7bf1263fb5aafdaf904ed2f7db839f.tar.gz |
Merge branch 'pr-cmd-raise-with-stderr-on-error' of https://github.com/barry-scott/GitPython into barry-scott-pr-cmd-raise-with-stderr-on-error
Diffstat (limited to 'git/remote.py')
-rw-r--r-- | git/remote.py | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/git/remote.py b/git/remote.py index 42753977..12a681b0 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') @@ -631,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 |