]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
Add repo_utils.ls_remote()
authorZack Cerza <zack@redhat.com>
Wed, 19 Oct 2016 20:55:05 +0000 (14:55 -0600)
committerZack Cerza <zack@redhat.com>
Wed, 19 Oct 2016 20:55:05 +0000 (14:55 -0600)
... by moving most of suite.util.git_ls_remote's code to that module.

Signed-off-by: Zack Cerza <zack@redhat.com>
teuthology/repo_utils.py
teuthology/suite/util.py

index c57308eb3be8218e5727caa6852f90f99225f68d..a815f355497da9956e353ded9564aacdf075357f 100644 (file)
@@ -36,6 +36,20 @@ def is_fresh(path):
     return False
 
 
+def ls_remote(url, ref):
+    """
+    Return the current sha1 for a given repository and ref
+
+    :returns: The sha1 if found; else None
+    """
+    cmd = "git ls-remote {} {}".format(url, ref)
+    result = subprocess.check_output(
+        cmd, shell=True).split()
+    sha1 = result[0] if result else None
+    log.debug("{} -> {}".format(cmd, sha1))
+    return sha1
+
+
 def enforce_repo_state(repo_url, dest_path, branch, remove_on_error=True):
     """
     Use git to either clone or update a given repo, forcing it to switch to the
index 4f7cf99df9e3b4947690ea54da60edee1cad7989..7dd78c010b701c3e3fe297fc498ee9203df6ed9d 100644 (file)
@@ -11,6 +11,7 @@ import sys
 from email.mime.text import MIMEText
 
 from .. import lock
+from .. import repo_utils
 
 from ..config import config
 from ..exceptions import BranchNotFoundError, ScheduleFailError
@@ -175,12 +176,7 @@ def git_ls_remote(project, branch, project_owner='ceph'):
     :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
+    return repo_utils.ls_remote(url, branch)
 
 
 def git_validate_sha1(project, sha1, project_owner='ceph'):