move git repository existence check out of getvar
authorTimo Savola <tsavola@movial.fi>
Fri, 4 Apr 2008 14:06:15 +0000 (17:06 +0300)
committerTimo Savola <tsavola@movial.fi>
Fri, 4 Apr 2008 14:07:03 +0000 (17:07 +0300)
matrix/git.py
matrix/matrix.py

index 9a53d0f..16530f7 100644 (file)
@@ -171,8 +171,6 @@ def rev_parse(name, arg):
                return None
 
 def getvar(name,var):
-       if not os.path.exists(name):
-               return None
        res=call_output(['config',var],workdir=name)
        if res and len(res)==1:
                return res[0]
@@ -238,3 +236,6 @@ def cat_file(name, hash, blob=False, size=False):
 
 def log(name, options, fd=None):
        return call_output(['log'] + options + ['--'], workdir=name, fd=fd)
+
+def contains_database(name):
+       return os.path.exists(os.path.join(name, '.git'))
index c59fed7..d03bbd5 100644 (file)
@@ -190,12 +190,13 @@ def update_component_url(c):
        update_repository_url(c.meta)
 
 def update_repository_url(repo):
-       url = git.getvar(repo.path, 'remote.origin.url')
-       if url:
-               repo.active_url = url
-               if config.debug:
-                       print 'Using', repo.active_url
-               return
+       if git.contains_database(repo.path):
+               url = git.getvar(repo.path, 'remote.origin.url')
+               if url:
+                       repo.active_url = url
+                       if config.debug:
+                               print 'Using', repo.active_url
+                       return
 
        for root in config.roots:
                for suffix in ('.git', ''):