Skip to content

test: cover ambiguous hunk id error path#84

Merged
wkentaro merged 1 commit into
mainfrom
test/ambiguous-hunk-id-error
Jun 26, 2026
Merged

test: cover ambiguous hunk id error path#84
wkentaro merged 1 commit into
mainfrom
test/ambiguous-hunk-id-error

Conversation

@wkentaro

Copy link
Copy Markdown
Owner

_find_hunks_by_ids raises ambiguous hunk id '<prefix>' when a partial id
matches more than one hunk, but that branch had no test. This adds an e2e test
that provokes it: with more than 16 hunks, two ids must share a leading hex
char (pigeonhole over the 16 possible hex digits), so a single-char prefix is
ambiguous. The test finds such a prefix, stages it, and asserts the error fires
and nothing is staged.

Test plan

  • uv run pytest tests/e2e/error_test.py::test_ambiguous_hunk_id_rejected
  • make test (246 passed)
  • make lint

A single hex-char prefix that matches more than one hunk hits the
'ambiguous hunk id' branch in _find_hunks_by_ids, which had no coverage.
Pigeonhole on the first hex char of 20 hunk ids guarantees a collision.
@wkentaro wkentaro self-assigned this Jun 25, 2026
@wkentaro

Copy link
Copy Markdown
Owner Author

This was generated by AI during PR processing.

Finalized. Single clean commit adding an integration test for the ambiguous hunk-id error path; drives the real CLI, no mocks. Pigeonhole reasoning (20 hunks > 16 hex chars) soundly guarantees a single-char prefix collision, and the test asserts both the non-zero exit with ambiguous in stderr and that nothing is staged.

  • Branch is current with main (0 commits behind base, merge state CLEAN) — no rebase needed.
  • /code-review (medium): no meaningful findings.
  • /recommit: history already clean (one atomic, well-named commit) — no-op.
  • CI: all 7 checks green; verified the new test passes locally.

Verdict: recommend-merge.

@wkentaro wkentaro added the recommend-merge pr: Agent finalized and endorses it: review and merge label Jun 25, 2026
@wkentaro

Copy link
Copy Markdown
Owner Author

This was generated by AI during PR processing.

Verdict: recommend-merge

Reviewed at medium effort (correctness + conventions). The PR adds a single, well-scoped e2e test covering the ambiguous-hunk-id rejection path on stage.

  • The pigeonhole setup is sound: 20 hunks over 16 possible leading hex chars guarantees a colliding single-char prefix, and the Counter/next search correctly finds that guaranteed collision rather than assuming ids[0] collides.
  • The test asserts the right things: non-zero exit, "ambiguous" in stderr, and (crucially) that nothing was staged (git diff --cached empty).
  • CI is green across all 7 jobs (lint + ubuntu/macos/windows × 3.10/3.14).

Branch is fully current with main (0 commits behind, merge state CLEAN), single clean commit, no push needed this tick. Ready for maintainer review and merge.

@wkentaro wkentaro added this to the next milestone Jun 26, 2026
@wkentaro wkentaro merged commit c935314 into main Jun 26, 2026
7 checks passed
@wkentaro wkentaro deleted the test/ambiguous-hunk-id-error branch June 26, 2026 07:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

recommend-merge pr: Agent finalized and endorses it: review and merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant