fix local repositories
authorTimo Savola <tsavola@movial.fi>
Tue, 20 May 2008 08:09:33 +0000 (11:09 +0300)
committerTimo Savola <tsavola@movial.fi>
Tue, 20 May 2008 08:09:33 +0000 (11:09 +0300)
also use ls-remote instead of the deprecated peek-remote, and show its
output when debug enabled.

matrix/git.py
matrix/repositories.py

index a705b97c598347448f7422ce239ba62ea12cc35a..c6d8a9aeae2df2ff9761189004b5cd41ef3c2c6b 100644 (file)
@@ -37,7 +37,7 @@ def call(args, workdir=None, quiet=False, fail=False):
                        if workdir:
                                os.chdir(workdir)
 
-                       if quiet:
+                       if quiet and not config.debug:
                                fd = os.open('/dev/null', os.O_WRONLY)
                                os.dup2(fd, 1)
                                os.dup2(fd, 2)
@@ -123,9 +123,14 @@ def call_output(args, workdir=None, fd=None, lines=True, wait=True, any=False):
                else:
                        return contents
 
-def peek_remote(url, quiet=False):
-       args = ['peek-remote', url]
-       return call(args, quiet=quiet, fail=not quiet) == 0
+def url_exists(url):
+       if ':' not in url and os.path.isdir(url):
+               if config.debug:
+                       'Local directory:', url
+               return True
+
+       args = ['ls-remote', '-h', url]
+       return call(args, quiet=True, fail=False) == 0
 
 def clone(name, url, checkout=True):
        options = []
index dd071715a6b471ad43ff011e96ad1c3689318aea..b1d0cc701be1748948ff5025ab74cb7c1c490ca3 100644 (file)
@@ -47,10 +47,11 @@ class Repository(object):
                                if config.debug:
                                        print 'Trying', url
 
-                               if git.peek_remote(url, quiet=True):
+                               if git.url_exists(url):
                                        if self.branch:
-                                               branch = self.branch
-                                       return url, branch
+                                               return url, self.branch
+                                       else:
+                                               return url, branch
 
                raise Error('Failed to locate repository under any root: ' + \
                            '%s.git' % self.name)