From: Zack Cerza Date: Wed, 13 Apr 2016 18:27:03 +0000 (-0600) Subject: git_ls_remote(): Add debug output and docstring X-Git-Tag: 1.1.0~627^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ea4e9c05731e1af7da176b7eb8bbfc09ee0d1b3d;p=teuthology.git git_ls_remote(): Add debug output and docstring Signed-off-by: Zack Cerza --- diff --git a/teuthology/suite.py b/teuthology/suite.py index adec8c836..89b541c94 100644 --- a/teuthology/suite.py +++ b/teuthology/suite.py @@ -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'): """