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
2 changes: 2 additions & 0 deletions src/sentry/integrations/cursor_origin/webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,10 @@ def verify_delivery(request: HttpRequest, body: bytes) -> Verification:
"installation.suspended": InstallationRemovedHandler,
"installation.unsuspended": InstallationRestoredHandler,
"installation.updated": InstallationUpdatedHandler,
"pull_request.base_ref.updated": PullRequestLifecycleHandler,
"pull_request.closed": PullRequestLifecycleHandler,
"pull_request.created": PullRequestLifecycleHandler,
"pull_request.head_ref.pushed": PullRequestLifecycleHandler,
"pull_request.merged": PullRequestLifecycleHandler,
"pull_request.metadata.updated": PullRequestLifecycleHandler,
Comment thread
sentry[bot] marked this conversation as resolved.
"pull_request.published": PullRequestLifecycleHandler,
Expand Down
29 changes: 29 additions & 0 deletions tests/sentry/integrations/cursor_origin/test_pull_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from sentry.constants import ObjectStatus
from sentry.integrations.cursor_origin.pull_request import PullRequestLifecycleHandler
from sentry.integrations.cursor_origin.webhook import HANDLERS
from sentry.integrations.cursor_origin.webhook_types import OriginPayloadError, PullRequestEvent
from sentry.integrations.services.integration import integration_service
from sentry.models.pullrequest import PullRequest, PullRequestLifecycleState
Expand Down Expand Up @@ -127,6 +128,34 @@ def test_a_later_event_updates_the_same_row(self) -> None:
assert len(pull_requests) == 1
assert pull_requests[0].title == "Add launch telemetry, take two"

def test_a_push_to_the_head_branch_moves_the_head_commit(self) -> None:
"""`head_ref.pushed` carries the same snapshot, with the new tip."""
self._handle(_payload())
self._handle(
_payload(
head={"ref": "add-telemetry", "sha": "c0ffee00"}, updatedAt="2026-08-01T11:00:00Z"
)
)

assert self._pull_requests()[0].head_commit_sha == "c0ffee00"

def test_every_lifecycle_event_is_routed_to_the_handler(self) -> None:
"""Origin sends the whole pull request with each of these, so one handler serves all."""
routed = sorted(
event for event, handler in HANDLERS.items() if handler is PullRequestLifecycleHandler
)

assert routed == [
"pull_request.base_ref.updated",
"pull_request.closed",
"pull_request.created",
"pull_request.head_ref.pushed",
"pull_request.merged",
"pull_request.metadata.updated",
"pull_request.published",
"pull_request.reopened",
]

def test_a_stale_snapshot_is_dropped(self) -> None:
"""Deliveries can arrive out of order, so the shared upsert compares timestamps."""
self._handle(
Expand Down
Loading