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
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class IntegrationRepository(TypedDict):
identifier: str
isInstalled: bool
defaultBranch: str | None
externalId: str


@cell_silo_endpoint
Expand Down Expand Up @@ -85,6 +86,7 @@ def get(
identifier=repo["identifier"],
defaultBranch=repo.get("default_branch"),
isInstalled=repo["identifier"] in installed_repo_names,
externalId=repo["external_id"],
)
for repo in repositories
if not installable_only or repo["identifier"] not in installed_repo_names
Expand Down
3 changes: 3 additions & 0 deletions tests/acceptance/test_scm_onboarding.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def test_scm_onboarding_happy_path(self) -> None:
"name": "sentry",
"identifier": "getsentry/sentry",
"default_branch": "master",
"external_id": "12345",
},
]

Expand Down Expand Up @@ -162,6 +163,7 @@ def test_scm_onboarding_with_integration_install(self) -> None:
"name": "sentry",
"identifier": "getsentry/sentry",
"default_branch": "master",
"external_id": "12345",
},
]

Expand Down Expand Up @@ -273,6 +275,7 @@ def test_scm_onboarding_detection_error_falls_back_to_manual_picker(self) -> Non
"name": "sentry",
"identifier": "getsentry/sentry",
"default_branch": "master",
"external_id": "12345",
},
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@ def setUp(self) -> None:
)
def test_simple(self, get_repositories: MagicMock) -> None:
get_repositories.return_value = [
{"name": "rad-repo", "identifier": "Example/rad-repo", "default_branch": "main"},
{"name": "cool-repo", "identifier": "Example/cool-repo"},
{
"name": "rad-repo",
"identifier": "Example/rad-repo",
"default_branch": "main",
"external_id": "rad-repo",
},
{"name": "cool-repo", "identifier": "Example/cool-repo", "external_id": "cool-repo"},
]
response = self.client.get(self.path, format="json")

Expand All @@ -35,12 +40,14 @@ def test_simple(self, get_repositories: MagicMock) -> None:
"identifier": "Example/rad-repo",
"defaultBranch": "main",
"isInstalled": False,
"externalId": "rad-repo",
},
{
"name": "cool-repo",
"identifier": "Example/cool-repo",
"defaultBranch": None,
"isInstalled": False,
"externalId": "cool-repo",
},
],
"searchable": True,
Expand All @@ -55,8 +62,9 @@ def test_hide_hidden_repos(self, get_repositories: MagicMock) -> None:
"name": "rad-repo",
"identifier": "Example/rad-repo",
"default_branch": "main",
"external_id": "rad-repo",
},
{"name": "cool-repo", "identifier": "Example/cool-repo"},
{"name": "cool-repo", "identifier": "Example/cool-repo", "external_id": "cool-repo"},
]

self.create_repo(
Expand All @@ -75,6 +83,7 @@ def test_hide_hidden_repos(self, get_repositories: MagicMock) -> None:
"identifier": "Example/cool-repo",
"defaultBranch": None,
"isInstalled": False,
"externalId": "cool-repo",
},
],
"searchable": True,
Expand All @@ -85,9 +94,23 @@ def test_hide_hidden_repos(self, get_repositories: MagicMock) -> None:
)
def test_installable_only(self, get_repositories: MagicMock) -> None:
get_repositories.return_value = [
{"name": "rad-repo", "identifier": "Example/rad-repo", "default_branch": "main"},
{"name": "cool-repo", "identifier": "Example/cool-repo", "default_branch": "dev"},
{"name": "awesome-repo", "identifier": "Example/awesome-repo"},
{
"name": "rad-repo",
"identifier": "Example/rad-repo",
"default_branch": "main",
"external_id": "rad-repo",
},
{
"name": "cool-repo",
"identifier": "Example/cool-repo",
"default_branch": "dev",
"external_id": "cool-repo",
},
{
"name": "awesome-repo",
"identifier": "Example/awesome-repo",
"external_id": "awesome-repo",
},
]

self.create_repo(
Expand All @@ -105,12 +128,14 @@ def test_installable_only(self, get_repositories: MagicMock) -> None:
"identifier": "Example/cool-repo",
"defaultBranch": "dev",
"isInstalled": False,
"externalId": "cool-repo",
},
{
"name": "awesome-repo",
"identifier": "Example/awesome-repo",
"defaultBranch": None,
"isInstalled": False,
"externalId": "awesome-repo",
},
],
"searchable": True,
Expand All @@ -121,8 +146,18 @@ def test_installable_only(self, get_repositories: MagicMock) -> None:
)
def test_is_installed_field(self, get_repositories: MagicMock) -> None:
get_repositories.return_value = [
{"name": "rad-repo", "identifier": "Example/rad-repo", "default_branch": "main"},
{"name": "rad-repo", "identifier": "Example2/rad-repo", "default_branch": "dev"},
{
"name": "rad-repo",
"identifier": "Example/rad-repo",
"default_branch": "main",
"external_id": "rad-repo",
},
{
"name": "rad-repo",
"identifier": "Example2/rad-repo",
"default_branch": "dev",
"external_id": "rad-repo",
},
]

self.create_repo(
Expand All @@ -141,11 +176,13 @@ def test_is_installed_field(self, get_repositories: MagicMock) -> None:
"identifier": "Example/rad-repo",
"defaultBranch": "main",
"isInstalled": True,
"externalId": "rad-repo",
},
{
"name": "rad-repo",
"identifier": "Example2/rad-repo",
"defaultBranch": "dev",
"externalId": "rad-repo",
"isInstalled": False,
},
],
Expand All @@ -161,7 +198,12 @@ def test_repo_installed_by_other_org_not_excluded(self, get_repositories: MagicM
one organization should not affect the available repos for the other.
"""
get_repositories.return_value = [
{"name": "shared-repo", "identifier": "Example/shared-repo", "default_branch": "main"},
{
"name": "shared-repo",
"identifier": "Example/shared-repo",
"default_branch": "main",
"external_id": "shared-repo",
},
]

other_org = self.create_organization(owner=self.user, name="other-org")
Expand All @@ -182,6 +224,7 @@ def test_repo_installed_by_other_org_not_excluded(self, get_repositories: MagicM
"identifier": "Example/shared-repo",
"defaultBranch": "main",
"isInstalled": False,
"externalId": "shared-repo",
},
],
"searchable": True,
Expand All @@ -193,7 +236,12 @@ def test_repo_installed_by_other_org_not_excluded(self, get_repositories: MagicM
def test_accessible_only_passes_param(self, get_repositories: MagicMock) -> None:
"""When accessibleOnly=true, passes accessible_only to get_repositories."""
get_repositories.return_value = [
{"name": "rad-repo", "identifier": "Example/rad-repo", "default_branch": "main"},
{
"name": "rad-repo",
"identifier": "Example/rad-repo",
"default_branch": "main",
"external_id": "rad-repo",
},
]
response = self.client.get(
self.path, format="json", data={"search": "rad", "accessibleOnly": "true"}
Expand All @@ -208,6 +256,7 @@ def test_accessible_only_passes_param(self, get_repositories: MagicMock) -> None
"identifier": "Example/rad-repo",
"defaultBranch": "main",
"isInstalled": False,
"externalId": "rad-repo",
},
],
"searchable": True,
Expand All @@ -219,7 +268,12 @@ def test_accessible_only_passes_param(self, get_repositories: MagicMock) -> None
def test_accessible_only_without_search(self, get_repositories: MagicMock) -> None:
"""When accessibleOnly=true but no search, passes both params through."""
get_repositories.return_value = [
{"name": "rad-repo", "identifier": "Example/rad-repo", "default_branch": "main"},
{
"name": "rad-repo",
"identifier": "Example/rad-repo",
"default_branch": "main",
"external_id": "rad-repo",
},
]
response = self.client.get(self.path, format="json", data={"accessibleOnly": "true"})

Expand All @@ -232,8 +286,18 @@ def test_accessible_only_without_search(self, get_repositories: MagicMock) -> No
def test_accessible_only_with_installable_only(self, get_repositories: MagicMock) -> None:
"""Both filters compose: accessible scopes the fetch, installable excludes installed repos."""
get_repositories.return_value = [
{"name": "rad-repo", "identifier": "Example/rad-repo", "default_branch": "main"},
{"name": "cool-repo", "identifier": "Example/cool-repo", "default_branch": "dev"},
{
"name": "rad-repo",
"identifier": "Example/rad-repo",
"default_branch": "main",
"external_id": "rad-repo",
},
{
"name": "cool-repo",
"identifier": "Example/cool-repo",
"default_branch": "dev",
"external_id": "cool-repo",
},
]

self.create_repo(
Expand All @@ -257,6 +321,7 @@ def test_accessible_only_with_installable_only(self, get_repositories: MagicMock
"identifier": "Example/cool-repo",
"defaultBranch": "dev",
"isInstalled": False,
"externalId": "cool-repo",
},
],
"searchable": True,
Expand Down
Loading