fj pr comment: add edit/delete + idempotent --edit-last/--create-if-none #131
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Task
Bring
fj pr commentup to parity withfj issue commentand add the idempotent-upsert flags both sides need:fj pr comment edit <comment-id>andfj pr comment delete <comment-id>, calling the already-presentapi::issue::edit_comment/delete_comment(src/api/issue.rs:216-232) that the issue side already uses. In Forgejo a PR is an issue, so comment mutation shares the/repos/{owner}/{repo}/issues/comments/{id}path; no new API code. Mirrorsrc/cli/issue_comment.rs.--edit-lastand--create-if-noneto BOTHfj issue commentandfj pr comment: list the authenticated user's comments on the target, pick the most recent one authored by the token user, and edit it (create when none exists). This is the gh-parity idempotency primitive.Source: rasterstate/fj#120.
Priority
p2. The single-maintained-status-comment pattern (bot posts "build running", edits it to "build green") is the canonical bot/CI use, and
--edit-last/--create-if-noneis what collapses the read-modify-write dance into one call. One notch below the p1 scripting-blockers because a workingfj apifallback (hand-managed comment id) exists today.Reason
fj pr commentis write-once:CommentArgscarries onlynumber+bodyand the handler only posts (src/cli/pr.rs:234,:592); there is noEditComment/DeleteCommentverb, unlike the issue side (src/cli/issue.rs:40-44). The write endpoints already exist and already work for PRs, so the gap is purely a missing CLI verb. Even on the issue side, edit/delete exist but there is no idempotency flag, so a bot mustview --comments --json, grep its own marker, extract the id, and branch on existence for every update.Acceptance
fj pr comment edit <id> --body ...andfj pr comment delete <id>work, reusingapi::issue::edit_comment/delete_comment.--edit-lastedits the token user's most recent comment on the target;--create-if-nonecreates one when none exists; both work onfj issue commentandfj pr comment.--body,--body -(stdin), and$EDITORfallback all compose with the new flags.src/client/integration_tests.rsfor edit, delete, and the edit-last/create-if-none selection.cargo fmt --check,cargo clippy --all-targets --all-features -- -D warnings, andcargo test --allpass.Dependencies
None. Reuses existing comment-mutation endpoints and the
src/cli/issue_comment.rsshape. Pairs with rasterstate/fj#124 (-F/--body-file) since maintained status comments are usually generated bodies.Size
M
fj pr commentis write-once: no edit/delete, no--edit-last/--create-if-none, unlikefj issue#120