Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/sentry/features/temporary.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ def register_temporary_features(manager: FeatureManager) -> None:
manager.add("organizations:github-repo-auto-sync", OrganizationFeature, FeatureHandlerStrategy.FLAGPOLE, api_expose=False)
manager.add("organizations:github-repo-auto-sync-apply", OrganizationFeature, FeatureHandlerStrategy.FLAGPOLE, api_expose=False)
manager.add("organizations:github-repo-auto-sync-webhook", OrganizationFeature, FeatureHandlerStrategy.FLAGPOLE, api_expose=False)
manager.add("organizations:scm-repo-auto-sync-removal", OrganizationFeature, FeatureHandlerStrategy.FLAGPOLE, api_expose=False)
manager.add("organizations:github_enterprise-repo-auto-sync", OrganizationFeature, FeatureHandlerStrategy.FLAGPOLE, api_expose=False)
manager.add("organizations:github_enterprise-repo-auto-sync-apply", OrganizationFeature, FeatureHandlerStrategy.FLAGPOLE, api_expose=False)
manager.add("organizations:gitlab-repo-auto-sync", OrganizationFeature, FeatureHandlerStrategy.FLAGPOLE, api_expose=False)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def _sync_repos_for_org(
provider=integration.provider,
)

if repos_removed:
if repos_removed and features.has("organizations:scm-repo-auto-sync-removal", rpc_org):
# Look up repos before disabling to get their IDs and names
external_ids = [str(repo["id"]) for repo in repos_removed]
existing_repos = repository_service.get_repositories(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def sync_repos_for_org(organization_integration_id: int) -> None:
provider=provider_key,
)

if removed_ids:
if removed_ids and _has_feature("organizations:scm-repo-auto-sync-removal", rpc_org):
repository_service.disable_repositories_by_external_ids(
organization_id=organization_id,
integration_id=integration.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from sentry.testutils.silo import assume_test_silo_mode, assume_test_silo_mode_of, control_silo_test

FEATURE_FLAG = "organizations:github-repo-auto-sync-webhook"
REMOVAL_FLAG = "organizations:scm-repo-auto-sync-removal"


@control_silo_test
Expand Down Expand Up @@ -70,7 +71,7 @@ def test_repos_removed(self, _: MagicMock) -> None:
status=ObjectStatus.ACTIVE,
)

with self.feature(FEATURE_FLAG):
with self.feature([FEATURE_FLAG, REMOVAL_FLAG]):
sync_repos_on_install_change(
integration_id=self.integration.id,
action="removed",
Expand Down Expand Up @@ -100,7 +101,7 @@ def test_mixed_add_and_remove(self, _: MagicMock) -> None:
status=ObjectStatus.ACTIVE,
)

with self.feature(FEATURE_FLAG):
with self.feature([FEATURE_FLAG, REMOVAL_FLAG]):
sync_repos_on_install_change(
integration_id=self.integration.id,
action="added",
Expand Down
20 changes: 18 additions & 2 deletions tests/sentry/integrations/github/test_webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,15 @@ def test_end_to_end_repos_added(self) -> None:
)
sha1, sha256 = self._compute_signatures(body)

with self.feature("organizations:github-repo-auto-sync-webhook"), self.tasks():
with (
self.feature(
[
"organizations:github-repo-auto-sync-webhook",
"organizations:scm-repo-auto-sync-removal",
]
),
self.tasks(),
):
response = self.client.post(
path=self.url,
data=body,
Expand Down Expand Up @@ -483,7 +491,15 @@ def test_end_to_end_repos_removed(self, mock_seer_cleanup: MagicMock) -> None:
)
sha1, sha256 = self._compute_signatures(body)

with self.feature("organizations:github-repo-auto-sync-webhook"), self.tasks():
with (
self.feature(
[
"organizations:github-repo-auto-sync-webhook",
"organizations:scm-repo-auto-sync-removal",
]
),
self.tasks(),
):
response = self.client.post(
path=self.url,
data=body,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@ def test_disables_removed_repos(self, _: MagicMock) -> None:
self._add_repos_response([{"id": 1, "full_name": "getsentry/sentry", "name": "sentry"}])

with self.feature(
["organizations:github-repo-auto-sync", "organizations:github-repo-auto-sync-apply"]
[
"organizations:github-repo-auto-sync",
"organizations:github-repo-auto-sync-apply",
"organizations:scm-repo-auto-sync-removal",
]
):
sync_repos_for_org(self.oi.id)

Expand Down
Loading