add missing parameter to latest_revision(), reduce verbosity
authorAndreas Oberritter <obi@saftware.de>
Fri, 6 Nov 2009 12:00:47 +0000 (13:00 +0100)
committerAndreas Oberritter <obi@saftware.de>
Fri, 6 Nov 2009 12:00:47 +0000 (13:00 +0100)
lib/bb/fetch/git.py

index 09625b9..b25fd4c 100644 (file)
@@ -35,7 +35,7 @@ def prunedir(topdir):
         for name in dirs:
             os.rmdir(os.path.join(root, name))
 
-def rungitcmd(cmd,d):
+def runfetchcmd(cmd, d, quiet = False):
 
     bb.debug(1, "Running %s" % cmd)
 
@@ -51,7 +51,8 @@ def rungitcmd(cmd,d):
         line = stdout_handle.readline()
         if not line:
             break
-        print line
+        if not quiet:
+            print line
         output += line
 
     status =  stdout_handle.close() or 0
@@ -66,10 +67,10 @@ def rungitcmd(cmd,d):
     return output
 
 def contains_ref(tag, d):
-    output = rungitcmd("git log --pretty=oneline -n 1 %s -- 2> /dev/null | wc -l" % tag, d)
+    output = runfetchcmd("git log --pretty=oneline -n 1 %s -- 2> /dev/null | wc -l" % tag, d, True)
     return output.split()[0] != "0"
 
-def latest_revision(proto, user, host, path, branch):
+def latest_revision(proto, user, host, path, branch, d):
     """
     Compute the HEAD revision for the url
     """
@@ -78,7 +79,7 @@ def latest_revision(proto, user, host, path, branch):
     else:
         username = ""
 
-    output = rungitcmd("git ls-remote %s://%s%s%s %s" % (proto, username, host, path, branch), d)
+    output = runfetchcmd("git ls-remote %s://%s%s%s %s" % (proto, username, host, path, branch), d, True)
     return output.split()[0]
 
 def getbranch(parm):
@@ -91,13 +92,13 @@ def getbranch(parm):
 
     return branch
 
-def gettag(parm, proto, user, host, path, branch):
+def gettag(parm, proto, user, host, path, branch, d):
     if 'tag' in parm:
         tag = parm['tag']
     else:
-        tag = latest_revision(proto, user, host, path, branch)
+        tag = latest_revision(proto, user, host, path, branch, d)
     if not tag or tag == "master":
-        tag = latest_revision(proto, user, host, path, branch)
+        tag = latest_revision(proto, user, host, path, branch, d)
 
     return tag
 
@@ -121,7 +122,7 @@ def localfile(url, d):
 
     proto = getprotocol(parm)
     branch = getbranch(parm)
-    tag = gettag(parm, proto, user, host, path, branch)
+    tag = gettag(parm, proto, user, host, path, branch, d)
 
     return data.expand('git_%s%s_%s.tar.gz' % (host, path.replace('/', '.'), tag), d)
 
@@ -151,7 +152,7 @@ class Git(Fetch):
 
             proto = getprotocol(parm)
             branch = getbranch(parm)
-            tag = gettag(parm, proto, user, host, path, branch)
+            tag = gettag(parm, proto, user, host, path, branch, d)
 
             if user:
                 username = user + '@'
@@ -171,31 +172,31 @@ class Git(Fetch):
                 if Fetch.try_mirror(d, repofilename):    
                     bb.mkdirhier(repodir)
                     os.chdir(repodir)
-                    rungitcmd("tar -xzf %s" % (repofile),d)
+                    runfetchcmd("tar -xzf %s" % (repofile),d)
                 else:
-                    rungitcmd("git clone -n %s://%s%s%s %s" % (proto, username, host, path, repodir),d)
+                    runfetchcmd("git clone -n %s://%s%s%s %s" % (proto, username, host, path, repodir),d)
 
             os.chdir(repodir)
             # Remove all but the .git directory
             if not contains_ref(tag, d):
-                rungitcmd("rm * -Rf", d)
-                rungitcmd("git fetch %s://%s%s%s %s" % (proto, username, host, path, branch), d)
-                rungitcmd("git fetch --tags %s://%s%s%s" % (proto, username, host, path), d)
-                rungitcmd("git prune-packed", d)
-                rungitcmd("git pack-redundant --all | xargs -r rm", d)
+                runfetchcmd("rm * -Rf", d)
+                runfetchcmd("git fetch %s://%s%s%s %s" % (proto, username, host, path, branch), d)
+                runfetchcmd("git fetch --tags %s://%s%s%s" % (proto, username, host, path), d)
+                runfetchcmd("git prune-packed", d)
+                runfetchcmd("git pack-redundant --all | xargs -r rm", d)
 
             os.chdir(repodir)
             bb.note("Creating tarball of git repository")
-            rungitcmd("tar -czf %s %s" % (repofile, os.path.join(".", ".git", "*") ),d)
+            runfetchcmd("tar -czf %s %s" % (repofile, os.path.join(".", ".git", "*") ),d)
 
             if os.path.exists(codir):
                 prunedir(codir)
 
             bb.mkdirhier(codir)
             os.chdir(repodir)
-            rungitcmd("git read-tree %s" % (tag),d)
-            rungitcmd("git checkout-index -q -f --prefix=%s -a" % (os.path.join(codir, "git", "")),d)
+            runfetchcmd("git read-tree %s" % (tag),d)
+            runfetchcmd("git checkout-index -q -f --prefix=%s -a" % (os.path.join(codir, "git", "")),d)
 
             os.chdir(codir)
             bb.note("Creating tarball of git checkout")
-            rungitcmd("tar -czf %s %s" % (self.localpath(loc, d), os.path.join(".", "*") ),d)
+            runfetchcmd("tar -czf %s %s" % (self.localpath(loc, d), os.path.join(".", "*") ),d)