feat: surface inline-comment anchor fields on pr view --reviews (task 0034)
Each inline review comment under `pr view <n> --reviews` now renders its `id` (the handle a reply targets), `resolved` (`yes`/`no`, from whether Gitea populated the comment's `resolver`), and `diff_hunk`. The hunk is structurally trimmed to its `@@` header line plus its last two lines by default (hunks of three lines or fewer are left whole) and emitted verbatim under `--full`, so the trim never touches the char-based body truncation path. The raw `position`/`original_position` diff offsets stay unsurfaced. The fields ride the existing reviews-plus-per-review-comments fetch — no extra API calls.
This commit is contained in:
17
src/diff.ts
17
src/diff.ts
@@ -56,3 +56,20 @@ export function truncateDiff(diff: string, full: boolean): DiffResult {
|
||||
original_length: diff.length,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Structurally trim a review comment's `diff_hunk` to its anchor: the `@@`
|
||||
* header line plus the hunk's last two lines. A hunk of three lines or fewer is
|
||||
* already covered by that (header + last two), so it is returned unchanged.
|
||||
*
|
||||
* This is deliberately not the char-based body truncation: it keeps both the
|
||||
* file-line anchor (the `@@` header) and the code at the comment (the tail),
|
||||
* which a keep-head char truncation would get backwards by dropping the tail.
|
||||
*/
|
||||
export function trimDiffHunk(hunk: string): string {
|
||||
const lines = hunk.split("\n");
|
||||
if (lines.length <= 3) {
|
||||
return hunk;
|
||||
}
|
||||
return [lines[0], ...lines.slice(-2)].join("\n");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user