Repository navigation
Add the ability to delete the "last" comment, similar to --edit-last #10366
Description
Activity
Would be happy to try and submit a PR for this, similar to #6384
- addedgh-prrelating to the gh pr commandrelating to the gh pr commandgh-issuerelating to the gh issue commandrelating to the gh issue command
on Feb 4, 2025 Hey @erawhctim, this is an interesting idea... I am slightly concerned around unintentional deletion, such as if the latest comment isn't what you thought it was. I think we can probably mitigate this with a confirmation flag like we do in a lot of
deletecommands, though its a bit awkward given its a flag and another flag. Not unprecedented, though, like with the--accept-visibility-change-consequencesflag in thegh repo edit --visibilitycommand.As such, I think my design would be as such:
Acceptance Criteria
Given I have commented on an open PR
when I invokegh pr comment [<number> | <url> | <branch>] --delete-lastinteractively
then I am shown the comment I will be deleting and prompted to confirm deletion. If deletion is confirmed, the comment is deleted.Given I have not commented on an open PR
when I invokegh pr comment [<number> | <url> | <branch>] --delete-last
then the command fails and I'm shown a message stating I haven't commented on the PR yetGiven I have commented on an open PR
when I invokegh pr comment [<number> | <url> | <branch>] --delete-last --yesinteractively
then the last pr comment I made is deleted and I am shown a deletion success messageGiven I have commented on an open PR
when I invokegh pr comment [<number> | <url> | <branch>] --delete-lastnon-interactively
then the command fails and I'm shown a message stating that I must use the--yesflag with the--delete-lastflag when using the flag non-interactivelyGiven I have commented on an open PR
when I invokegh pr comment [<number> | <url> | <branch>] --delete-last --yesnon-interactively
then the last pr comment I made is deletedGiven all of the above scenarios for an issue
when I invoke the correspondinggh issue comment command
then I experience the same behavior as the correspondinggh pr commentscenarios above
(i.e.gh issue comment --delete-lastshould behave the same asgh pr comment --delete-lastas enumerated by the AC above)Did I miss anything?
Reacted by Mitch Ware- addedhelp wantedContributions welcomeContributions welcomeand removedneeds-triageneeds to be reviewedneeds to be reviewed
on Feb 4, 2025 I think you nailed it.
Reacted by Tyler McGoffinAwesome! Feel free to take a stab at it, @erawhctim, if you're still interested
@jtmcg I am interested to take stab at it. Is it OK to split the PR into 2 parts (i.e. 1 for issue and 1 for PR)?
@sinansonmez feel free to tackle all of it at once if you'd prefer
Reacted by Sinan Sonmez (Chaush)@sinansonmez, you're welcome to break it up as well, though there's a lot of shared code between issues/prs that might make it easier to do all at once. Either way, feel free to work however you'd prefer 🙂
Reacted by Sinan Sonmez (Chaush)@jtmcg yes you were right, it was much easier than I though to implement all at once thanks to the shared code. Please take a look at the PR when you have time 😄
Reacted by Tyler McGoffin
Describe the feature or problem you’d like to solve
I'd love to see a way to delete PR and issue comments with the CLI.
This previous issue highlighted some questions/friction around a potential
delete --id 1234type command, which I think are valid concerns.I'd like to propose an ability to delete comments by building off of the existing behavior of
--edit-lastProposed solution
gh [issue|pr] comment --edit-last --deleteorgh [issue|pr] comment --delete-lastThis command would remove the last comment made by the CLI user, similar to how
--edit-lastworks.--edit-lastflag)Additional context
I don't think this would totally solve all the requests for a "delete comment" type command. It may solve a portion of them (e.g. use cases that leverage CI bots to leave comments) - maybe that is an acceptable compromise.