fix(post): anchor inline review comments via new_position (Gitea 1.26.x)
Gitea 1.26.x's POST /pulls/{i}/reviews does NOT honor the line/side fields
used by newer Gitea — it silently drops them, leaving the comment unpositioned.
Gitea then renders a file-level review comment on EVERY diff line of the file,
so a 5-finding review on a 25-line diff showed ~125 comment blocks in the
Files Changed view (the flood reported on canalhandia PR #2).
The 1.26 schema anchors inline review comments with new_position (line in the
post-change file) + old_position: 0. f["line"] is already a validated
post-change (RIGHT-side) line from split_findings, so it maps directly to
new_position. Verified: new_position=98 -> position=98 + populated diff_hunk
(positioned, renders on line 98 only); the old line/side form -> position=0,
empty diff_hunk (unpositioned).
49 tests pass (no test asserted the POST payload shape).
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
+10
-5
@@ -626,15 +626,20 @@ def post_inline_review(
|
|||||||
) -> None:
|
) -> None:
|
||||||
"""Post a review with a summary body AND positional inline comments.
|
"""Post a review with a summary body AND positional inline comments.
|
||||||
|
|
||||||
Each anchored finding becomes one entry in `comments`:
|
Each anchored finding becomes one entry in `comments`. Gitea 1.26.x anchors
|
||||||
{path, side:"RIGHT", line, body}. The body carries the ```suggestion
|
inline review comments with `new_position` (the line in the POST-change file)
|
||||||
fence when the model produced replacement code.
|
+ `old_position: 0` — the `line`/`side` fields used by newer Gitea are NOT
|
||||||
|
honored here and silently leave the comment unpositioned (Gitea then renders
|
||||||
|
a file-level comment on EVERY diff line of the file, which is the flood we
|
||||||
|
hit). `f["line"]` is already a validated post-change (RIGHT-side) line from
|
||||||
|
`split_findings`, so it maps directly to `new_position`. The body carries the
|
||||||
|
```suggestion fence when the model produced replacement code.
|
||||||
"""
|
"""
|
||||||
comments = [
|
comments = [
|
||||||
{
|
{
|
||||||
"path": f["path"],
|
"path": f["path"],
|
||||||
"side": "RIGHT",
|
"new_position": f["line"],
|
||||||
"line": f["line"],
|
"old_position": 0,
|
||||||
"body": inline_comment_body(f),
|
"body": inline_comment_body(f),
|
||||||
}
|
}
|
||||||
for f in anchored
|
for f in anchored
|
||||||
|
|||||||
Reference in New Issue
Block a user