fix(robomp): thread commit_id/head_sha/patch through proxy backend

Follow-up fix round for 71d608aae6 (validate PR review comment
anchors against the diff before submitting). The validation path
broke in several places the original commit did not cover:

- GitHubBackend.submit_review gained no commit_id parameter, so
  submitting through GitHubProxyClient raised a production
  TypeError on a path the validation code depended on.
- PullRequestInfo lacked head_sha, so the Forgejo commit_id
  fallback raised AttributeError; it is now parsed in
  _pr_from_payload and carried through the proxy round-trip.
- _pr_file_from dropped the file patch, silently no-oping anchor
  validation for anything routed through the proxy; the patch is
  now forwarded.
- The hunk parser treated any +++/--- line as a file header,
  desyncing line counters when added/removed content began with
  those prefixes; file headers are now recognized only before
  the first hunk.
- Reworded the comment to "Forgejo only" to match the actual
  backend behavior.

Adds tests for forgejo commit_id fetch, fallback double-failure,
empty-patch fail-open, LEFT-side anchoring, proxy commit_id
validation, and file-creation hunk boundaries.
This commit is contained in:
djdembeck
2026-08-18 16:25:52 -05:00
parent 71d608aae6
commit e599d58f21
8 changed files with 419 additions and 37 deletions
+6 -1
View File
@@ -124,7 +124,11 @@ def test_get_pull_request_parses_head_repo_and_author() -> None:
json={
"number": 9,
"html_url": "https://github.com/octo/widget/pull/9",
"head": {"ref": "farm/abc12345/fix", "repo": {"full_name": "octo/widget"}},
"head": {
"ref": "farm/abc12345/fix",
"sha": "abc1234567890123456789012345678901234567",
"repo": {"full_name": "octo/widget"},
},
"base": {"ref": "main"},
"state": "open",
"user": {"login": "robomp-bot"},
@@ -134,6 +138,7 @@ def test_get_pull_request_parses_head_repo_and_author() -> None:
client = GitHubClient("tok", transport=httpx.MockTransport(handler))
pr = _run_async(client.get_pull_request("octo/widget", 9))
assert pr.head_ref == "farm/abc12345/fix"
assert pr.head_sha == "abc1234567890123456789012345678901234567"
assert pr.head_repo == "octo/widget"
assert pr.author == "robomp-bot"