From ea4e9c05731e1af7da176b7eb8bbfc09ee0d1b3d Mon Sep 17 00:00:00 2001 From: Zack Cerza Date: Wed, 13 Apr 2016 12:27:03 -0600 Subject: [PATCH] git_ls_remote(): Add debug output and docstring Signed-off-by: Zack Cerza --- teuthology/suite.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) 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'): """ -- 2.47.3