]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
git_ls_remote(): Add debug output and docstring
authorZack Cerza <zack@redhat.com>
Wed, 13 Apr 2016 18:27:03 +0000 (12:27 -0600)
committerZack Cerza <zack@redhat.com>
Wed, 13 Apr 2016 18:27:03 +0000 (12:27 -0600)
Signed-off-by: Zack Cerza <zack@redhat.com>
teuthology/suite.py

index adec8c836e683d1c5d817334a03c2cd9bc1e2f0f..89b541c946ff1f978e178344ca6610d04ad2d789 100644 (file)
@@ -539,14 +539,21 @@ def package_version_for_hash(hash, kernel_flavor='basic',
     if resp.ok:
         return resp.text.strip()
 
+
 def git_ls_remote(project, branch, project_owner='ceph'):
-    ls_remote = subprocess.check_output(
-        "git ls-remote " + build_git_url(project, project_owner) + " " +
-        branch, shell=True).split()
-    if ls_remote:
-        return ls_remote[0]
-    else:
-        return None
+    """
+    Find the latest sha1 for a given project's branch.
+
+    :returns: The sha1 if found; else None
+    """
+    url = build_git_url(project, project_owner)
+    cmd = "git ls-remote {} {}".format(url, branch)
+    result = subprocess.check_output(
+        cmd, shell=True).split()
+    sha1 = result[0] if result else None
+    log.debug("{} -> {}".format(cmd, sha1))
+    return sha1
+
 
 def build_git_url(project, project_owner='ceph'):
     """