| @@ -210,7 +210,7 @@ def test_todo_ingestion_is_idempotent(db_session) -> None: |
| 210 | 210 | "results": [ |
| 211 | 211 | { |
| 212 | 212 | "id": "1001", |
| 213 | | "created": "2026-03-29T10:00:00Z", |
| 213 | "created": "2026-05-01T10:00:00Z", |
| 214 | 214 | "ticket": { |
| 215 | 215 | "id": "123", |
| 216 | 216 | "ref": "~ccleberg/todo/123", |
| @@ -229,7 +229,7 @@ def test_todo_ingestion_is_idempotent(db_session) -> None: |
| 229 | 229 | }, |
| 230 | 230 | { |
| 231 | 231 | "id": "1002", |
| 232 | | "created": "2026-03-30T09:00:00Z", |
| 232 | "created": "2026-05-02T09:00:00Z", |
| 233 | 233 | "ticket": { |
| 234 | 234 | "id": "123", |
| 235 | 235 | "ref": "~ccleberg/todo/123", |
| @@ -248,7 +248,7 @@ def test_todo_ingestion_is_idempotent(db_session) -> None: |
| 248 | 248 | }, |
| 249 | 249 | { |
| 250 | 250 | "id": "1003", |
| 251 | | "created": "2026-03-30T10:00:00Z", |
| 251 | "created": "2026-05-02T10:00:00Z", |
| 252 | 252 | "ticket": { |
| 253 | 253 | "id": "123", |
| 254 | 254 | "ref": "~ccleberg/todo/123", |
| @@ -507,6 +507,55 @@ def test_git_ingestion_auto_discovers_owned_repositories(db_session) -> None: |
| 507 | 507 | assert any("query UserRepositories" in call[0] for call in client.calls) |
| 508 | 508 | |
| 509 | 509 | |
| 510 | def test_git_ingestion_reads_repository_log_from_default_head_branch(db_session) -> None: |
| 511 | settings = make_settings( |
| 512 | ACTOR_ALIASES_JSON={"~ccleberg": ["cmc@example.com", "Chris Cleberg"]}, |
| 513 | GIT_TRACKED_REPOSITORIES=["Hutch"], |
| 514 | ) |
| 515 | git_payload = { |
| 516 | "user": { |
| 517 | "repository": { |
| 518 | "name": "Hutch", |
| 519 | "owner": {"canonicalName": "~ccleberg"}, |
| 520 | "HEAD": {"name": "refs/heads/trunk", "target": "abc123"}, |
| 521 | "log": { |
| 522 | "results": [ |
| 523 | { |
| 524 | "id": "abc123", |
| 525 | "shortId": "abc123", |
| 526 | "author": { |
| 527 | "name": "Chris Cleberg", |
| 528 | "email": "cmc@example.com", |
| 529 | "time": "2026-03-30T12:00:00Z", |
| 530 | }, |
| 531 | "committer": { |
| 532 | "name": "Chris Cleberg", |
| 533 | "email": "cmc@example.com", |
| 534 | "time": "2026-03-30T12:00:00Z", |
| 535 | }, |
| 536 | "message": "Commit on non-standard default branch", |
| 537 | } |
| 538 | ], |
| 539 | "cursor": None, |
| 540 | }, |
| 541 | } |
| 542 | } |
| 543 | } |
| 544 | client = StubClient(payloads_by_query={"query RepositoryLog": git_payload}) |
| 545 | git_service = GitIngestionService(client, settings) |
| 546 | |
| 547 | result = git_service.fetch_recent_events("~ccleberg", since=datetime(2026, 3, 1, tzinfo=UTC)) |
| 548 | |
| 549 | repository_log_calls = [call for call in client.calls if "query RepositoryLog" in call[0]] |
| 550 | assert len(result.events) == 1 |
| 551 | assert repository_log_calls[0][1] == { |
| 552 | "username": "ccleberg", |
| 553 | "repoName": "Hutch", |
| 554 | "cursor": None, |
| 555 | "from": "HEAD", |
| 556 | } |
| 557 | |
| 558 | |
| 510 | 559 | def test_sync_overlap_reuses_cursor_window_and_suppresses_duplicates(db_session) -> None: |
| 511 | 560 | settings = make_settings() |
| 512 | 561 | event = NormalizedEvent( |