Skip to content
Closed
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
3 changes: 2 additions & 1 deletion src/sentry/api/endpoints/project_repo_path_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ def integration_match(integration: RpcIntegration) -> bool:
return False

def repo_match(repo: Repository) -> bool:
return repo.url is not None and source_url.startswith(repo.url)
# End at a "/" so that "acme/app" doesn't claim "acme/app-v2" links.
return repo.url is not None and source_url.startswith(f"{repo.url.rstrip('/')}/")

# now find the matching integration
integrations = integration_service.get_integrations(
Expand Down
14 changes: 14 additions & 0 deletions tests/sentry/api/endpoints/test_project_repo_path_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,20 @@ def test_no_repo(self) -> None:
assert resp.status_code == 400, resp.content
assert resp.data == {"sourceUrl": ["Could not find repo"]}

def test_repo_with_shared_name_prefix(self) -> None:
sentry_native = self.create_repo(
project=self.project,
name="getsentry/sentry-native",
provider="integrations:github",
integration_id=self.integration.id,
url="https://github.com/getsentry/sentry-native",
)
source_url = "https://github.com/getsentry/sentry-native/blob/master/src/app/main.py"
stack_path = "app/main.py"
resp = self.make_post(source_url, stack_path)
assert resp.status_code == 200, resp.content
assert resp.data["repositoryId"] == sentry_native.id

def test_single_file_path(self) -> None:
source_url = (
"https://github.com/getsentry/sentry/blob/master/src/project_stacktrace_link.py"
Expand Down
Loading