Skip to content

Commit e47172f

Browse files
authored
feat(github-growth): allow hiding repos (#52766)
1 parent cae04f1 commit e47172f

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/sentry/api/endpoints/organization_repository_details.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class RepositorySerializer(serializers.Serializer):
2020
# XXX(dcramer): these are aliased, and we prefer 'active' over 'visible'
2121
("visible", "visible"),
2222
("active", "active"),
23+
("hidden", "hidden"),
2324
)
2425
)
2526
name = serializers.CharField(required=False)
@@ -53,6 +54,8 @@ def put(self, request: Request, organization, repo_id) -> Response:
5354
if result.get("status"):
5455
if result["status"] in ("visible", "active"):
5556
update_kwargs["status"] = ObjectStatus.ACTIVE
57+
elif result["status"] == "hidden":
58+
update_kwargs["status"] = ObjectStatus.HIDDEN
5659
else:
5760
raise NotImplementedError
5861
if result.get("integrationId"):

tests/sentry/api/endpoints/test_organization_repository_details.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,26 @@ def test_put_cancel_deletion(self):
247247
organization_id=org.id, key=repo.build_pending_deletion_key()
248248
).exists()
249249

250+
def test_put_hide_repo(self):
251+
self.login_as(user=self.user)
252+
253+
org = self.create_organization(owner=self.user, name="baz")
254+
255+
repo = Repository.objects.create(
256+
name="uuid-name",
257+
external_id="uuid-external-id",
258+
organization_id=org.id,
259+
status=ObjectStatus.ACTIVE,
260+
)
261+
262+
url = reverse("sentry-api-0-organization-repository-details", args=[org.slug, repo.id])
263+
response = self.client.put(url, data={"status": "hidden"})
264+
265+
assert response.status_code == 200
266+
267+
repo = Repository.objects.get(id=repo.id)
268+
assert repo.status == ObjectStatus.HIDDEN
269+
250270
def test_put_cancel_deletion_duplicate_exists(self):
251271
self.login_as(user=self.user)
252272

0 commit comments

Comments
 (0)