def sync_hooks(user_id, repositories):
"""Sync repository hooks for a user."""
from .api import GitHubAPI
try:
# Sync hooks
gh = GitHubAPI(user_id=user_id)
for repo_id in repositories:
try:
with db.session.begin_nested():
gh.sync_repo_hook(repo_id)
# We commit per repository, because while the task is running
# the user might enable/disable a hook.
db.session.commit()
except (NoResultFound, RepositoryAccessError) as e:
current_app.logger.warning(e.message, exc_info=True)
except Exception as exc:
sync_hooks.retry(exc=exc)
评论列表
文章目录