Gitea client: production review-policy client operations (#28) #31

Merged
pbwraith merged 3 commits from issue-28 into main 2026-08-29 09:51:20 +02:00

3 Commits

Author SHA1 Message Date
pbwraith-worker
f6b40d0108 fix(#28): merge_pr pins the reviewed head and fails closed on movement (bounce-fix) 2026-08-28 14:33:58 -05:00
Claude
1f2c85b4ff fix(#28): merge_pr must send MergePullRequestOption.Do + reviewed head_commit_id
The merge request previously posted an empty object, which this Gitea
instance's published MergePullRequestOption schema rejects. Post the
supported merge mode {"Do": "merge"} plus the head_commit_id read from
the PR, so a branch that moved after review cannot be merged
accidentally. Fail closed (GiteaClientError) when the PR record carries
no head commit id. Regression tests assert the exact request shape.
2026-08-28 14:13:50 -05:00
Claude
8b17668746 Gitea client: production review-policy client operations (#28)
Implement the review-policy protocol on the production GiteaClient:
- list_open_prs(repo): all open PRs, Gitea pagination, normalized shape
- add_label / remove_label: resolve repo label id, mutate, verify state
- merge_pr(repo, pr): merge endpoint + merged confirmation (bool)
- close_issue(repo, n): state update + closed confirmation
- get_pr() now returns the normalized candidate shape (number, body,
  head_sha, base_ref, labels as names, repo, changed_files)

Fail-closed: non-2xx responses raise GiteaApiError (token/authorization
header never leak, even when servers echo the request back); unknown
labels and failed post-condition verifications raise GiteaClientError.
Pagination has a defensive page cap.

Hermetic tests (tests/test_gitea_client.py) script a local threaded HTTP
stub and assert request methods, paths, bodies, pagination, normalized
results, failure handling, and a source-derived contract test that the
production client exposes every operation ReviewPolicy/reviewer call.
2026-08-28 13:39:26 -05:00