summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2015-01-06 12:22:16 +0100
committerSebastian Thiel <byronimo@gmail.com>2015-01-06 12:22:16 +0100
commit60e54133aa1105a1270f0a42e74813f75cd2dc46 (patch)
treec5d6a2c600ef7d9a66d8a11e1e474b921cccfb7d
parenta83eee5bcee64eeb000dd413ab55aa98dcc8c7f2 (diff)
downloadgitpython-60e54133aa1105a1270f0a42e74813f75cd2dc46.tar.gz
test_remote works
And I have to wonder why git-daemon serves under py2.7, but really wants receive-pack to be allowed under 3.4. Maybe it's a repository override which for some reason doesn't work in py3.4 ? Maybe because the change is not flushed ?
-rw-r--r--git/cmd.py2
-rw-r--r--git/exc.py10
-rw-r--r--git/remote.py10
-rw-r--r--git/repo/fun.py2
-rw-r--r--git/test/lib/helper.py11
5 files changed, 21 insertions, 14 deletions
diff --git a/git/cmd.py b/git/cmd.py
index 2bff3310..aac7ffb7 100644
--- a/git/cmd.py
+++ b/git/cmd.py
@@ -120,7 +120,7 @@ class Git(LazyMixin):
:raise GitCommandError: if the return status is not 0"""
status = self.proc.wait()
if status != 0:
- raise GitCommandError(self.args, status, self.proc.stderr.read())
+ raise GitCommandError(self.args, status, self.proc.stderr.read().decode(defenc))
# END status handling
return status
# END auto interrupt
diff --git a/git/exc.py b/git/exc.py
index ba57c624..67fb9894 100644
--- a/git/exc.py
+++ b/git/exc.py
@@ -29,10 +29,12 @@ class GitCommandError(Exception):
self.command = command
def __str__(self):
- ret = "'%s' returned exit status %i: %s" % \
- (' '.join(str(i) for i in self.command), self.status, self.stderr)
- if self.stdout is not None:
- ret += "\nstdout: %s" % self.stdout
+ ret = "'%s' returned with exit code %i" % \
+ (' '.join(str(i) for i in self.command), self.status)
+ if self.stderr:
+ ret += "\nstderr: '%s'" % self.stderr
+ if self.stdout:
+ ret += "\nstdout: '%s'" % self.stdout
return ret
diff --git a/git/remote.py b/git/remote.py
index 63f21c4e..484bc031 100644
--- a/git/remote.py
+++ b/git/remote.py
@@ -138,7 +138,7 @@ class PushInfo(object):
@classmethod
def _from_line(cls, remote, line):
"""Create a new PushInfo instance as parsed from line which is expected to be like
- refs/heads/master:refs/heads/master 05d2687..1d0568e"""
+ refs/heads/master:refs/heads/master 05d2687..1d0568e as bytes"""
control_character, from_to, summary = line.split('\t', 3)
flags = 0
@@ -522,6 +522,7 @@ class Remote(LazyMixin, Iterable):
def _get_fetch_info_from_stderr(self, proc, progress):
# skip first line as it is some remote info we are not interested in
+ # TODO: Use poll() to process stdout and stderr at same time
output = IterableList('name')
# lines which are no progress are fetch info lines
@@ -544,8 +545,8 @@ class Remote(LazyMixin, Iterable):
# END for each line
# read head information
- fp = open(join(self.repo.git_dir, 'FETCH_HEAD'), 'r')
- fetch_head_info = fp.readlines()
+ fp = open(join(self.repo.git_dir, 'FETCH_HEAD'), 'rb')
+ fetch_head_info = [l.decode(defenc) for l in fp.readlines()]
fp.close()
# NOTE: We assume to fetch at least enough progress lines to allow matching each fetch head line with it.
@@ -562,10 +563,12 @@ class Remote(LazyMixin, Iterable):
# we hope stdout can hold all the data, it should ...
# read the lines manually as it will use carriage returns between the messages
# to override the previous one. This is why we read the bytes manually
+ # TODO: poll() on file descriptors to know what to read next, process streams concurrently
digest_process_messages(proc.stderr, progress)
output = IterableList('name')
for line in proc.stdout.readlines():
+ line = line.decode(defenc)
try:
output.append(PushInfo._from_line(self, line))
except ValueError:
@@ -573,7 +576,6 @@ class Remote(LazyMixin, Iterable):
pass
# END exception handling
# END for each line
-
finalize_process(proc)
return output
diff --git a/git/repo/fun.py b/git/repo/fun.py
index 64b9b4a9..ac0fa6f1 100644
--- a/git/repo/fun.py
+++ b/git/repo/fun.py
@@ -21,7 +21,7 @@ __all__ = ('rev_parse', 'is_git_dir', 'touch', 'read_gitfile', 'find_git_dir', '
def touch(filename):
- fp = open(filename, "a")
+ fp = open(filename, "ab")
fp.close()
diff --git a/git/test/lib/helper.py b/git/test/lib/helper.py
index bc9c351a..eea594e7 100644
--- a/git/test/lib/helper.py
+++ b/git/test/lib/helper.py
@@ -193,7 +193,7 @@ def with_rw_and_rw_remote_repo(working_tree_ref):
temp_dir = os.path.dirname(_mktemp())
# On windows, this will fail ... we deal with failures anyway and default to telling the user to do it
try:
- gd = Git().daemon(temp_dir, as_process=True)
+ gd = Git().daemon(temp_dir, enable='receive-pack', as_process=True)
# yes, I know ... fortunately, this is always going to work if sleep time is just large enough
time.sleep(0.5)
except Exception:
@@ -215,7 +215,8 @@ def with_rw_and_rw_remote_repo(working_tree_ref):
msg += 'Otherwise, run: git-daemon "%s"' % temp_dir
raise AssertionError(msg)
else:
- msg = 'Please start a git-daemon to run this test, execute: git-daemon "%s"' % temp_dir
+ msg = 'Please start a git-daemon to run this test, execute: git daemon --enable=receive-pack "%s"'
+ msg %= temp_dir
raise AssertionError(msg)
# END make assertion
# END catch ls remote error
@@ -227,7 +228,8 @@ def with_rw_and_rw_remote_repo(working_tree_ref):
return func(self, rw_repo, rw_remote_repo)
finally:
# gd.proc.kill() ... no idea why that doesn't work
- os.kill(gd.proc.pid, 15)
+ if gd is not None:
+ os.kill(gd.proc.pid, 15)
os.chdir(prev_cwd)
rw_repo.git.clear_cache()
@@ -235,7 +237,8 @@ def with_rw_and_rw_remote_repo(working_tree_ref):
shutil.rmtree(repo_dir, onerror=_rmtree_onerror)
shutil.rmtree(remote_repo_dir, onerror=_rmtree_onerror)
- gd.proc.wait()
+ if gd is not None:
+ gd.proc.wait()
# END cleanup
# END bare repo creator
remote_repo_creator.__name__ = func.__name__