feat(repos): Add task to periodically sync repos from github#112043
feat(repos): Add task to periodically sync repos from github#112043
Conversation
Backend Test FailuresFailures on
|
9323c8d to
9a5dc41
Compare
dc6db0b to
04ffffa
Compare
e1110fd to
9e370c5
Compare
d147832 to
2e87a63
Compare
2e87a63 to
a342e00
Compare
This adds a task that runs every 24 hours to make sure that the available repositories on the github side match the repositories we have on the Sentry side.
b33f134 to
42a5298
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Autofix Details
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Duplicated
_get_repo_configalready exists inlink_all_repos- Removed the duplicated _get_repo_config function and imported get_repo_config from link_all_repos.py instead, following the existing pattern used by sync_repos_on_install_change.py.
Or push these changes by commenting:
@cursor push 240cd2d26b
Preview (240cd2d26b)
diff --git a/src/sentry/integrations/source_code_management/sync_repos.py b/src/sentry/integrations/source_code_management/sync_repos.py
--- a/src/sentry/integrations/source_code_management/sync_repos.py
+++ b/src/sentry/integrations/source_code_management/sync_repos.py
@@ -9,7 +9,6 @@
"""
import logging
-from collections.abc import Mapping
from datetime import timedelta
from typing import Any
@@ -18,6 +17,7 @@
from sentry import features
from sentry.constants import ObjectStatus
from sentry.features.exceptions import FeatureNotRegistered
+from sentry.integrations.github.tasks.link_all_repos import get_repo_config
from sentry.integrations.models.organization_integration import OrganizationIntegration
from sentry.integrations.services.integration import integration_service
from sentry.integrations.services.repository.service import repository_service
@@ -51,14 +51,6 @@
]
-def _get_repo_config(repo: Mapping[str, Any], integration_id: int) -> RepositoryInputConfig:
- return {
- "external_id": str(repo["id"]),
- "integration_id": integration_id,
- "identifier": repo["full_name"],
- }
-
-
def _has_feature(flag_name: str, org: Any) -> bool:
"""Check a feature flag, returning False if the flag is not registered."""
try:
@@ -206,7 +198,7 @@
if new_ids:
integration_repo_provider = get_integration_repository_provider(integration)
repo_configs: list[RepositoryInputConfig] = [
- _get_repo_config(repo, integration.id)
+ get_repo_config(repo, integration.id)
for repo in provider_repos
if str(repo["id"]) in new_ids
]This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.
Keep the sync task GitHub-specific for now. Generalizing to all SCMs requires a consistent way to extract external_id from each provider's API response, which needs a separate refactor. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 56bb0e1. Configure here.
markstory
left a comment
There was a problem hiding this comment.
Looks reasonable to me. client.get_repos() will fetch all repos with pagination so sync should be exhaustive. There are a lot of RPC calls in these tasks but there isn't a good way around that.
This adds a task that runs every 24 hours to make sure that the available repositories on the github side match the repositories we have on the Sentry side.


This adds a task that runs every 24 hours to make sure that the available repositories on the github side match the repositories we have on the Sentry side.