Skip to content

Commit

Permalink
remote, gitpython-developers#525: FIX BUG push-cmd misses error messages
Browse files Browse the repository at this point in the history
+ Bug discovered after enabling TC in prev commit and rework of fetch.
+ remote_tc: unitestize assertions.
+ util: DEL unused `_mktemp()`.

Conflicts:
	git/test/lib/helper.py
	git/test/test_remote.py
  • Loading branch information
ankostis committed Oct 13, 2016
1 parent 85f38a1 commit 57a6e9a
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 83 deletions.
2 changes: 1 addition & 1 deletion git/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def __del__(self):
def __getattr__(self, attr):
return getattr(self.proc, attr)

def wait(self, stderr=b''):
def wait(self, stderr=b''): # TODO: Bad choice to mimic `proc.wait()` but with different args.
"""Wait for the process and return its status code.
:param stderr: Previously read value of stderr, in case stderr is already closed.
Expand Down
14 changes: 8 additions & 6 deletions git/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
)
from git.util import (
join_path,
finalize_process
)
from git.cmd import handle_process_output, Git
from gitdb.util import join
Expand Down Expand Up @@ -681,16 +680,19 @@ def stdout_handler(line):
try:
output.append(PushInfo._from_line(self, line))
except ValueError:
# if an error happens, additional info is given which we cannot parse
# If an error happens, additional info is given which we parse below.
pass
# END exception handling
# END for each line

handle_process_output(proc, stdout_handler, progress_handler, finalizer=None, decode_streams=False)
stderr_text = progress.error_lines and '\n'.join(progress.error_lines) or ''
try:
handle_process_output(proc, stdout_handler, progress_handler, finalize_process, decode_streams=False)
proc.wait(stderr=stderr_text)
except Exception:
if len(output) == 0:
if not output:
raise
elif stderr_text:
log.warning("Error lines received while fetching: %s", stderr_text)

return output

def _assert_refspec(self):
Expand Down
24 changes: 8 additions & 16 deletions git/test/lib/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
import textwrap
import time
from unittest import TestCase
import unittest

from git.compat import string_types, is_win
from git.compat import string_types, is_win, PY3
from git.util import rmtree

import os.path as osp
Expand Down Expand Up @@ -68,18 +69,6 @@ def wait(self):
#{ Decorators


def _mktemp(*args):
"""Wrapper around default tempfile.mktemp to fix an osx issue
:note: the OSX special case was removed as it was unclear why that was needed in the first place. It seems
to be just fine without it. However, if we leave this special case, and if TMPDIR is set to something custom,
prefixing /private/ will lead to incorrect paths on OSX."""
tdir = tempfile.mktemp(*args)
# See :note: above to learn why this is comented out.
# if is_darwin:
# tdir = '/private' + tdir
return tdir


def with_rw_directory(func):
"""Create a temporary directory which can be written to, remove it if the
test succeeds, but leave it otherwise to aid additional debugging"""
Expand Down Expand Up @@ -129,7 +118,7 @@ def repo_creator(self):
if bare:
prefix = ''
# END handle prefix
repo_dir = _mktemp("%sbare_%s" % (prefix, func.__name__))
repo_dir = tempfile.mktemp("%sbare_%s" % (prefix, func.__name__))
rw_repo = self.rorepo.clone(repo_dir, shared=True, bare=bare, n=True)

rw_repo.head.commit = rw_repo.commit(working_tree_ref)
Expand Down Expand Up @@ -222,8 +211,8 @@ def argument_passer(func):

@wraps(func)
def remote_repo_creator(self):
remote_repo_dir = _mktemp("remote_repo_%s" % func.__name__)
repo_dir = _mktemp("remote_clone_non_bare_repo")
remote_repo_dir = tempfile.mktemp("remote_repo_%s" % func.__name__)
repo_dir = tempfile.mktemp("remote_clone_non_bare_repo")

rw_remote_repo = self.rorepo.clone(remote_repo_dir, shared=True, bare=True)
# recursive alternates info ?
Expand Down Expand Up @@ -340,6 +329,9 @@ class TestBase(TestCase):
of the project history ( to assure tests don't fail for others ).
"""

if not PY3:
assertRaisesRegex = unittest.TestCase.assertRaisesRegexp

def _small_repo_url(self):
""":return" a path to a small, clonable repository"""
from git.cmd import Git
Expand Down
Loading

0 comments on commit 57a6e9a

Please sign in to comment.