feat(review): add applicable code suggestions #1

Merged
lambadalambda merged 6 commits from feature/review-suggestions-v16 into v16.0/forgejo 2026-08-27 14:59:52 +00:00

Summary

  • backport Forgejo applicable review suggestions from upstream PR forgejo/forgejo#13023
  • support suggestion creation, preview, single apply, and atomic batch apply
  • support same-repository and fork pull requests

Pleroma hardening

  • bind apply requests to the exact comment content versions that were previewed
  • reject ambiguous legacy comments containing multiple suggestion blocks
  • require an exact stored preimage before applying multiline suggestions
  • preserve private author, committer, and co-author email settings
  • validate suggestion invariants at service boundaries and preflight API review batches

Testing

  • focused Go tests for Markdown parsing, preview generation, file splicing, preimage validation, and private attribution
  • SQLite integration suite for suggestion rendering, single and batch apply, stale/edit races, forks, permissions, and quotas
  • all suggestion integration tests pass

A full services/repository/files package run also encountered the sandbox's unrelated TestGetDiffPreview process restriction (operation not permitted); focused suggestion tests and the complete suggestion integration suite pass.

## Summary - backport Forgejo applicable review suggestions from upstream PR [forgejo/forgejo#13023](https://codeberg.org/forgejo/forgejo/pulls/13023) - support suggestion creation, preview, single apply, and atomic batch apply - support same-repository and fork pull requests ## Pleroma hardening - bind apply requests to the exact comment content versions that were previewed - reject ambiguous legacy comments containing multiple suggestion blocks - require an exact stored preimage before applying multiline suggestions - preserve private author, committer, and co-author email settings - validate suggestion invariants at service boundaries and preflight API review batches ## Testing - focused Go tests for Markdown parsing, preview generation, file splicing, preimage validation, and private attribution - SQLite integration suite for suggestion rendering, single and batch apply, stale/edit races, forks, permissions, and quotas - all suggestion integration tests pass A full `services/repository/files` package run also encountered the sandbox's unrelated `TestGetDiffPreview` process restriction (`operation not permitted`); focused suggestion tests and the complete suggestion integration suite pass.
Author
Owner

/oc review

/oc review
Author
Owner

Addressed both OpenCode P2 findings:

  • Pending review suggestions now render as plain code without apply/batch controls, matching apply-time eligibility (5c85e34f3b). Added an integration regression test.
  • Mixed-EOL files now use the dominant line ending when applying suggestions, with LF on ties (c7399227b1). Added LF-majority, CRLF-majority, and tie unit coverage.

Verification:

  • go test -tags 'sqlite sqlite_unlock_notify' ./services/repository/files -run '^Test(SuggestionCommitIdentityRespectsEmailPrivacy|SuggestionRangePreimage|SuggestionLines|SpliceLines)$' -count=1
  • go test -tags 'sqlite sqlite_unlock_notify' ./services/gitdiff -count=1
  • Complete suggestion SQLite integration suite (render, single/batch apply, fork, and quota cases)
Addressed both OpenCode P2 findings: - Pending review suggestions now render as plain code without apply/batch controls, matching apply-time eligibility (`5c85e34f3b`). Added an integration regression test. - Mixed-EOL files now use the dominant line ending when applying suggestions, with LF on ties (`c7399227b1`). Added LF-majority, CRLF-majority, and tie unit coverage. Verification: - `go test -tags 'sqlite sqlite_unlock_notify' ./services/repository/files -run '^Test(SuggestionCommitIdentityRespectsEmailPrivacy|SuggestionRangePreimage|SuggestionLines|SpliceLines)$' -count=1` - `go test -tags 'sqlite sqlite_unlock_notify' ./services/gitdiff -count=1` - Complete suggestion SQLite integration suite (render, single/batch apply, fork, and quota cases)
Author
Owner

/oc review

/oc review
Owner

OpenCode Review

Execution completed for pleroma/forgejo-custom at c7399227b1ee (job #48).

Rating: 5/5

The PR adds GitHub-style review suggestions: a ```suggestion fenced block with a server-rendered before/after preview in code comments, plus single and batch apply that commits to the PR head branch (fork-aware) with author/committer attribution and Co-authored-by trailers. Verification at head c739922: both previously reported P2s are fixed and covered by tests — pending-review comments no longer render or accept apply controls (SuggestionDiffs and resolveSuggestionEdit both gate on review state, with render and rejection integration tests), and apply now preserves the file's dominant line ending with LF on ties (unit coverage for LF/CRLF/tie). Independent checks: all touched Go packages build and vet cleanly; markdown, gitdiff, files, models/issues, services/pull and router unit tests pass; the complete new suggestion integration suites (render, single apply, batch, overlap, fork, quota, permissions, closed/merged/AGit gating) pass under sqlite; ESLint clean and webpack build succeeds. Security review confirms CSRF via the web route group, sign-in and repo assignment, comment-to-PR binding, head-branch write via CanMaintainerWriteToBranch, quota charged to the head-repo owner, LFS/binary/oversize rejection, exact preimage guards for multi-line writes, sound overlap and batch-limit handling, and archived-repo/closed-PR fail-closed behavior. Remaining observations (a no-op suggestion toolbar button when editing a code comment from the Conversation tab, uncached per-comment git check-attr during render, rare concurrent-apply race surfacing as a 500) are polish-level and non-blocking. Ready to merge.

No findings were reported.

Production-ready: both prior P2 findings verified fixed at head with regression coverage; builds, vet, unit tests, integration suites, lint and frontend build all pass locally; security and data-integrity gating on the new apply path is sound. No blocking or medium-impact defects found.

No companion fix was needed because the fresh review found no fixable findings.


Last reviewed commit: c7399227b1ee

<!-- opencode-review:v1:3885d2365e22e2037f35d20328f56cc8 --> <!-- opencode-reviewed-head:c7399227b1ee9784f4628245d8468cb0ee590498 --> ## OpenCode Review _Execution completed for `pleroma/forgejo-custom` at `c7399227b1ee` (job #48)._ Rating: **5/5** The PR adds GitHub-style review suggestions: a ```suggestion fenced block with a server-rendered before/after preview in code comments, plus single and batch apply that commits to the PR head branch (fork-aware) with author/committer attribution and Co-authored-by trailers. Verification at head c739922: both previously reported P2s are fixed and covered by tests — pending-review comments no longer render or accept apply controls (SuggestionDiffs and resolveSuggestionEdit both gate on review state, with render and rejection integration tests), and apply now preserves the file's dominant line ending with LF on ties (unit coverage for LF/CRLF/tie). Independent checks: all touched Go packages build and vet cleanly; markdown, gitdiff, files, models/issues, services/pull and router unit tests pass; the complete new suggestion integration suites (render, single apply, batch, overlap, fork, quota, permissions, closed/merged/AGit gating) pass under sqlite; ESLint clean and webpack build succeeds. Security review confirms CSRF via the web route group, sign-in and repo assignment, comment-to-PR binding, head-branch write via CanMaintainerWriteToBranch, quota charged to the head-repo owner, LFS/binary/oversize rejection, exact preimage guards for multi-line writes, sound overlap and batch-limit handling, and archived-repo/closed-PR fail-closed behavior. Remaining observations (a no-op suggestion toolbar button when editing a code comment from the Conversation tab, uncached per-comment git check-attr during render, rare concurrent-apply race surfacing as a 500) are polish-level and non-blocking. Ready to merge. No findings were reported. Production-ready: both prior P2 findings verified fixed at head with regression coverage; builds, vet, unit tests, integration suites, lint and frontend build all pass locally; security and data-integrity gating on the new apply path is sound. No blocking or medium-impact defects found. _No companion fix was needed because the fresh review found no fixable findings._ --- _Last reviewed commit: `c7399227b1ee`_
Author
Owner

/oc rerun

/oc rerun
Author
Owner

/oc fix latest

/oc fix latest
Author
Owner

/oc fix latest

/oc fix latest
Author
Owner

/oc fix latest

/oc fix latest
lambadalambda merged commit c8d23d82e5 into v16.0/forgejo 2026-08-27 14:59:52 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
pleroma/forgejo-custom!1
No description provided.