code: def sync_repo_hook(self, repo_id):
          
          # Get the hook that we may have set in the past
          gh_repo = self.api.repository_with_id(repo_id)
          hooks = (hook.id for hook in gh_repo.hooks()
                   if hook.config.get('url', '') == self.webhook_url)
          hook_id = next(hooks, None)
  
          # If hook on GitHub exists, get or create corresponding db object and
          # enable the hook. Otherwise remove the old hook information.
          if hook_id:
              Repository.enable(user_id=self.user_id,
                                github_id=gh_repo.id,
                                name=gh_repo.full_name,
                                hook=hook_id)
          else:
              Repository.disable(user_id=self.user_id,
                                 github_id=gh_repo.id,
                                 name=gh_repo.full_name)
docs: Sync a GitHub repo's hook with the locally stored repo.