def get_repository():
"""Get the GitHub repo specified in settings or the default.
If the repo doesn't exist, try to create it.
"""
try:
g = Github(**get_github_credentials())
if app_settings.GITHUB_ORG:
user = g.get_organization(app_settings.GITHUB_ORG)
else:
user = g.get_user()
try:
return user.get_repo(app_settings.GITHUB_REPO)
except UnknownObjectException:
logging.info("Creating repository {}".format(
app_settings.GITHUB_REPO
))
return user.create_repo(app_settings.GITHUB_REPO)
except GithubException:
logging.exception("Unable to configure Github connection.")
评论列表
文章目录