Repository navigation
Support updating comments/reviews #3613
Description
Activity
- changed the title
[-]Support updating comments[/-][+]Support updating comments/reviews[/+]on May 10, 2021 - addedcoreThis issue is not accepting PRs from outside contributorsThis issue is not accepting PRs from outside contributorsneeds-designAn engineering task needs design to proceedAn engineering task needs design to proceed
on May 18, 2021 This would be a really, reeeeally helpful enhancement, and obviate the need for a lot of custom actions / scripts that are currently needed to upsert comments on a PR. 🙏🏽
Reacted by Pete Steyert-WoodsShould be possible to delete comments as well.
- addedhelp wantedContributions welcomeContributions welcomeand removedneeds-designAn engineering task needs design to proceedAn engineering task needs design to proceedcoreThis issue is not accepting PRs from outside contributorsThis issue is not accepting PRs from outside contributors
on May 16, 2022 We've discussed this and decided that due to UI concerns, we wouldn't add a command to edit a comment by ID, since the user would be burdened with having to discover that ID in the first place, but we are open to a contribution that adds a command or flag that edits one's own last comment in a thread.
For example:
gh issue comment 123 --edit-last #=> edit my own last comment in issue thread #123How does this sound?
That would cover my use case, at least (a bot that comments helm chart diffs)
@pete-woods @mnquintana Thanks for chiming in. Does the bot ever need to perform an upsert, meaning "use this text to create a new comment or update an existing one"? Do you feel that should be exposed as part of this functionality as well?
I thought that was the same as the previous thing you said. The bot wants to update its single comment with the latest version of the diff.
Reacted by quanwfTo clarify, the first thing I said was a feature that only edits an existing comment by the same actor. If the comment to edit does not exist, the operation would fail.
An "upsert" is a single operation that would (in the context of comments) edit an existing comment, and create a comment if one by the same actor doesn't exist. I thought that the upsert operation might be useful for bots.
Okay, got it. So what I need is definitely to be able to "upsert" somehow. Though I don't mind if it's multiple commands (like finding if I've already commented and then using an update comment command), as long as I don't have to start using curl.
We've discussed this and decided that due to UI concerns, we wouldn't add a command to edit a comment by ID, since the user would be burdened with having to discover that ID in the first place, but we are open to a contribution that adds a command or flag that edits one's own last comment in a thread.
Personally, I don't think needing to first find a comment's ID and then updating via that ID should be a blocker to supporting the ability to update comments directly. I mostly use gh CLI for scripting and often need to first find the PR or issue number before I can run commands against that issue, so I don't see why I wouldn't be able to do the same thing for comments.
I would be fine with an
--edit-lastflag as it would solve my immediate use case. But I think gh CLI would be incomplete without a way to edit comments directly. Especially since you can already do it via the rest API (although its a lot more code)Reacted by Steffen Schneider, Pete Steyert-Woods, Jason Goldfine-Middleton, ryosebach, Andrei Neculau, Emily Bourne, tndhagedorn, Andrii Pavlenko, Noé, Emilgardis and 4 moreWe've discussed this and decided that due to UI concerns, we wouldn't add a command to edit a comment by ID, since the user would be burdened with having to discover that ID in the first place, but we are open to a contribution that adds a command or flag that edits one's own last comment in a thread.
Personally, I don't think needing to first find a comment's ID and then updating via that ID should be a blocker to supporting the ability to update comments directly. I mostly use gh CLI for scripting and often need to first find the PR or issue number before I can run commands against that issue, so I don't see why I wouldn't be able to do the same thing for comments.
I would be fine with an
--edit-lastflag as it would solve my immediate use case. But I think gh CLI would be incomplete without a way to edit comments directly. Especially since you can already do it via the rest API (although its a lot more code)I think
--edit-lastis a great solution for a lot of use cases, and I also agree with @Pearce-Ropion that it may not cover all use cases.I may have a CI workflow that needs to post and then later update different comments on the PR. It might post one comment to link to build artifacts, and append this as the build progresses. Another comment might be updated to show test results as they progress.
It's true there's no standard approach to search for the comment to update, In my case I just index comments using a tag hidden inside an HTML comment at the start of the comment:
<!--tag-->I can then find the comment to update with something like:
gh api \ -H "Accept: application/vnd.github+json" \ -H "X-GitHub-Api-Version: 2022-11-28" \ /repos/OWNER/REPO/issues/PULL_NUMBER/comments --jq 'map(select(.body|startswith("<!--tag-->"))) | .[0].id'Would it be possible to add the removal/deletion behavior that works similar to
--edit-last?
e.g.gh pr comment --edit-last --deleteorgh pr comment --remove-lastThat way, deleting would be possible without the burden of associating a comment to an ID value.
Created a new issue for this so we can keep this thread dead - #10366
Describe the feature or problem you’d like to solve
As part of CI, I'd like to drop a comment with the metrics of the PR.
For example like codecov does with coverage report.
As the PR is updated, I'd like to delete my initial comment and create a new one, or update my original comment.
Proposed solution
commentcommands should support accepting a comment reference for example--update issuecomment-123123123and update the comment instead of creating a new one.--json commentsshould include comment IDs to be able to query them via jq.