You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add --edit-last-or-create option or enhance the functionality of --edit-last for PR comments #6790
Describe the feature or problem you’d like to solve
Currently running gh pr comment --edit-last will fail if there is not an existing comment from the author. It would be nice to prompt users and/or allow users to use the option (or a new option) that will edit the last comment if it it exists but creates a new one if not.
❯ gh pr comment 5 --edit-last --body 'This is just a test'
no comments found for current user
Proposed solution
Add an additional option for gh pr comment such as --edit-last-or-create that will not fail if the user hasn't yet commented on the PR, it will simply create a new comment.
❯ gh pr comment 5 --edit-last-or-create --body 'This is just a test'
https://github.com/joe-sharp/<redacted>/pull/5#issuecomment-<redacted>
How will it benefit CLI and its users?
Script writers will no longer need to worry about making a conditional to check if a comment exists before running the command. This is useful for commenting the results of a build or linting job without polluting the PR with multiple comments.
Additional context
Please let me know if additional context is needed, but this should be pretty straight forward.
Reacted by Seito Tanaka, William Roberts, Michihito Shigemura, Deepak Kumar, Jean-Sebastien A. Beaudry, Miloš Lajtman, Kimura (Yamakado) Nobuhiro , Han Qiao, Joabe da Luz, toro_ponz and 19 more
changed the title [-]Add --edit-last-if-exists option or enhance the functionality of --edit-last for PR comments[/-][+]Add --edit-last-or-create option or enhance the functionality of --edit-last for PR comments[/+]on Dec 27, 2022
I was kinda leaning to just asking for that but decided I wanted to be open to other options. IMO the expected behavior would be to have it just work, but the warning is nice too. Maybe a config option could be added to change the warning to an error?
If neither build summaries or this scripting approach works for you, we can talk about adding a new flag. There is internal resistance to making --edit-last an upsert action.
The feature you pointed out won't work for us because we use other CI providers mostly. We did end up doing something similar to your last comment. I would think an extra flag would be useful and completely understand the pushback to modifying the existing flag.
I'm personally okay with an an --create-or-edit-last <body> flag that's mutually exclusive with --edit-last but would appreciate sign-off from @mislav and @samcoe . I see the merit for this kind of operation in non-Actions contexts and the bit of bash I pasted is a bit cumbersome.
I am glad there was resistance on making the existing action an upsert action because now we actually rely on that due to a feature change in the script. Anyways, just wanted to update to say we are no longer blocked by this feature request but maybe someday having a --upsert action might be nice.
Activity
[-]Add --edit-last-if-exists option or enhance the functionality of --edit-last for PR comments[/-][+]Add --edit-last-or-create option or enhance the functionality of --edit-last for PR comments[/+]vilmibm commentedon Jan 3, 2023
I'm wondering if there is harm in just having --edit-last just make a comment if no previous comment exists? we could output a warning, like:
Adding the discuss label for our next sync meeting.
joe-sharp commentedon Jan 3, 2023
I was kinda leaning to just asking for that but decided I wanted to be open to other options. IMO the expected behavior would be to have it just work, but the warning is nice too. Maybe a config option could be added to change the warning to an error?
vilmibm commentedon Jan 9, 2023
Actually, does this feature help your use case? https://github.blog/2022-05-09-supercharging-github-actions-with-job-summaries/
vilmibm commentedon Jan 9, 2023
Another option is to do something like this in your script:
If neither build summaries or this scripting approach works for you, we can talk about adding a new flag. There is internal resistance to making
--edit-lastan upsert action.joe-sharp commentedon Feb 3, 2023
The feature you pointed out won't work for us because we use other CI providers mostly. We did end up doing something similar to your last comment. I would think an extra flag would be useful and completely understand the pushback to modifying the existing flag.
kumadee commentedon Mar 1, 2023
I would appreciate if we had another flag which can enable upsert action to satisfy any resistance.
joe-sharp commentedon Mar 13, 2023
@vilmibm sorry for the ping. Just wanted to get this back on your radar.
vilmibm commentedon Mar 14, 2023
I'm personally okay with an an
--create-or-edit-last <body>flag that's mutually exclusive with--edit-lastbut would appreciate sign-off from @mislav and @samcoe . I see the merit for this kind of operation in non-Actions contexts and the bit of bash I pasted is a bit cumbersome.samcoe commentedon Mar 16, 2023
@vilmibm I am still on the fence but I won't stand in the way of this feature getting implemented.
joe-sharp commentedon May 27, 2023
I am glad there was resistance on making the existing action an upsert action because now we actually rely on that due to a feature change in the script. Anyways, just wanted to update to say we are no longer blocked by this feature request but maybe someday having a
--upsertaction might be nice.Shion1305 commentedon Feb 2, 2024
I'm interested in this feature. Will work on this.
vyacheslav31 commentedon Aug 7, 2024
Would love for one of the proposals on this issue to go through - any one of them would work nicely with my current ci/cd setup.
GriceTurrble commentedon Mar 11, 2025
FYI, duplicated by #10370 , which was fixed by #10427 .