Add edit/delete and idempotent upsert to pr comment #145
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/131-pr-comment-edit"
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?
Closes the write-once gap in
fj pr commentfrom rasterstate/fj#131: thecommand carried only
number+bodyand could only post, while the issueside already had edit/delete. Since a PR is an issue in Forgejo, comment
mutation shares the
issues/comments/{id}path, so this is purely a missingCLI verb plus the gh-parity upsert flag.
What changed
fj pr comment edit <id>andfj pr comment delete <id>, reusing theexisting
api::issue::edit_comment/delete_comment. Delete keeps thetype-the-id confirmation (skippable with
-y).--edit-lastretargets the add form at your most recent comment on the PR(selected by the monotonic comment id, not list order), erroring clearly
when you have none.
--create-if-noneposts a fresh comment when you have none yet;--create-or-editis the shorthand for--edit-last --create-if-none.Together they collapse the "build running → build green" maintained-status
comment dance into one idempotent call, no hand-managed comment id.
--body,--body -(stdin), and the$EDITORfallback all compose withthe new flags. The bare
fj pr comment <number>add form stays the default.pr.rsinto a newcli::pr_commentmodule.Scoped to the pr comment command only: the issue side and the error layer are
untouched.
Tests
pr_comment_edit_last_selects_callers_newest_comment: drives the fullfetch-user → list → PATCH sequence and asserts the selection lands on the
caller's newest comment, not a later one by someone else.
pr_comment_create_if_none_posts_when_caller_has_no_comment: no own comment→ selection is
None→ POST a new one.pr_comment_edit_and_delete_missing_id_error: a missing id surfaces the API404 for both edit and delete.
last_own_commentselection helper (newest-wins, absentlogin, empty list).
Fixes rasterstate/fj#131