code: def _sync_hooks(self, repos, asynchronous=True):
          
          if not asynchronous:
              for repo_id in repos:
                  try:
                      with db.session.begin_nested():
                          self.sync_repo_hook(repo_id)
                      db.session.commit()
                  except RepositoryAccessError as e:
                      current_app.logger.warning(e.message, exc_info=True)
                  except NoResultFound:
                      pass  # Repository not in DB yet
          else:
              # FIXME: We have to commit, in order to have all necessary data?
              db.session.commit()
              sync_hooks.delay(self.user_id, repos)
docs: Check if a hooks sync task needs to be started.