def read_branch(repo_path, name):
"""
Read branch and get HEAD sha
:param repo_path: Path to repo of branch
:param name: Name of branch to read
:returns: SHA of HEAD or None if branch is not found
"""
url = 'repos/%s/git/refs/heads/%s' % (repo_path, name)
app.logger.debug('GET: %s', url)
resp = github.get(url)
# Branch doesn't exist
if resp.status == 404:
return None
if resp.status != 200:
log_error('Failed reading branch', url, resp)
return None
return resp.data['object']['sha']
评论列表
文章目录