changeset 4518:8cf1d694bda0

vcs: introduce hack for handling git failure on --depth cloning (Issue #33)
author Mads Kiilerich <madski@unity3d.com>
date Wed, 24 Sep 2014 14:24:40 +0200
parents 2f18ebfead0c
children 5f13634aa7be
files kallithea/lib/vcs/subprocessio.py
diffstat 1 files changed, 12 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/lib/vcs/subprocessio.py	Wed Sep 24 14:24:40 2014 +0200
+++ b/kallithea/lib/vcs/subprocessio.py	Wed Sep 24 14:24:40 2014 +0200
@@ -375,14 +375,20 @@
             except Exception:
                 pass
             bg_out.stop()
+            out = ''.join(bg_out)
             bg_err.stop()
-            err = '%s' % ''.join(bg_err)
-            if err:
+            err = ''.join(bg_err)
+            if (err.strip() == 'fatal: The remote end hung up unexpectedly' and
+                out.startswith('0034shallow ')):
+                # hack inspired by https://github.com/schacon/grack/pull/7
+                bg_out = iter([out])
+                _p = None
+            elif err:
                 raise EnvironmentError(
                     "Subprocess exited due to an error:\n" + err)
-            raise EnvironmentError(
-                "Subprocess exited with non 0 ret code:%s" % _returncode)
-
+            else:
+                raise EnvironmentError(
+                    "Subprocess exited with non 0 ret code:%s" % _returncode)
         self.process = _p
         self.output = bg_out
         self.error = bg_err
@@ -392,7 +398,7 @@
         return self
 
     def next(self):
-        if self.process.poll():
+        if self.process and self.process.poll():
             err = '%s' % ''.join(self.error)
             raise EnvironmentError("Subprocess exited due to an error:\n" + err)
         return self.output.next()