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'):
"""