feat: delete previous review before posting new one (#6) #22
Reference in New Issue
Block a user
Delete Branch "feat/6-update-existing-review"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Before posting a review, the bot now:
GET /api/v1/userto identify its own loginThis keeps PR threads clean — one review per bot at any time.
New Gitea client methods
GetAuthenticatedUser()— token self-identificationListReviews()— fetch reviews on a PRDeleteReview()— delete a review by IDFlag
--update-existing/UPDATE_EXISTING(defaulttrue)Set to
falseto preserve old behavior (stack reviews).All delete failures are non-fatal (logged as warnings).
Closes #6
dd6c6c610fto2287a8238cGpt Review
Summary
This change implements robust duplicate review cleanup, adds targeted review sentinel logic, and enhances configuration and documentation for specialized review workflows. All code is thoroughly tested and idiomatic.
Recommendation
APPROVE — The implementation is correct, thoroughly tested, and aligns well with Go and repository conventions. New features (review cleanup, escalations, system prompt support) are composable and safe by default. All APIs are well-encapsulated, and the action/docs reflect the feature set. No changes required.
Review by gpt
Security Review
Summary
The changes add safe review cleanup and optional system prompt loading with appropriate validation and authorization checks. No exploitable vulnerabilities were identified, and CI passed.
Recommendation
APPROVE — The new features (sentinel-based cleanup, worst-wins escalation, and system-prompt-file support) are implemented with solid security considerations: reviewer-name is validated, deletion is restricted to the same authenticated user and matching sentinel, and system prompt file reading is constrained to the workspace with symlink checks. HTTP calls use auth headers without leaking secrets in logs. Approve as submitted.
Review by security
Sonnet Review
Summary
Solid feature addition with good tests and CI passing. However, there is a logic flaw when escalating an APPROVED review to REQUEST_CHANGES: the event is changed but the review body still reflects the original APPROVE verdict, which is misleading.
Findings
cmd/review-bot/main.gogitea/client.goRecommendation
REQUEST_CHANGES — Overall the changes are well-structured, follow repository conventions, and include thorough tests. CI has passed. However, before merging, address the escalation mismatch: when escalating an APPROVED review to REQUEST_CHANGES, rebuild the review body to reflect the REQUEST_CHANGES verdict. For example, clone the parsed result, set Verdict to "REQUEST_CHANGES", regenerate the body via review.FormatMarkdown, and post that. Alternatively, adjust the existing body’s recommendation section to reflect the escalated verdict. Also consider harmonizing owner/repo URL construction in the Gitea client by path-escaping owner and repo across all endpoints for consistency. With these fixes, the PR can be safely merged.
Review by sonnet