Repository navigation
gh pr comment --edit-last does not proceed if no comment already exists for the user #10370
Description
Activity
- changed the title
[-]`gh pr comment --édit-last` does not proceed if no comment already exists for the user[/-][+]`gh pr comment --edit-last` does not proceed if no comment already exists for the user[/+]on Feb 4, 2025 Hey @EdouardF, I could see how that might be a convenient addition to
gh pr comment --edit-last. I think the right approach, here, is not to add this functionality natively to--edit-last, but instead add a flag for non-TTY use-cases and a prompt for TTY use cases.It's worth calling out that
gh issue commentuses a lot of the same code, here, so we probably want to maintain parity between those two experiences. My proposed AC is below:Acceptance Criteria
Given I have no comments on an existing PR
when I rungh pr comment [<number> | <url> | <branch>] --edit-last --create-if-none --body <body>(non-interactively)
then a comment is created instead of erroringGiven I have no comments on an existing PR
when I rungh pr comment [<number> | <url> | <branch>] --edit-last(interactively)
then I am prompted that no comment exists and whether or not I'd like to create a new comment. If I select Y, then I have the same experience as though I rangh pr comment [<number> | <url> | <branch>]Given I have no comments on an existing PR
when I rungh pr comment [<number> | <url> | <branch>] --edit-last --create-if-none(interactively)
then I am told that no comments exist and I am creating a new comment. Then I have the same experience as though I rangh pr comment [<number> | <url> | <branch>]Given I have no comments on an existing issue
when I run any of the above scenarios usinggh issue comment
then I have get the same behavior as I would runninggh pr comment
(i.e. make suregh issue commentgets the same new functionality that's added togh pr commentby the above AC)Notes
- I think we can use a single
optto hold the flag value and use it for setting with the prompter. - We should probably make a new error for the condition where no comments exist and check for it in CommentableRun. We can then fall through to the
createCommentexperience from here if the new flag is set. Note: this might be an oversimplification of the problem, but I wanted to bread-crumb the implementation of this
- I think we can use a single
- addedgh-prrelating to the gh pr commandrelating to the gh pr commandhelp wantedContributions welcomeContributions welcomegh-issuerelating to the gh issue commandrelating to the gh issue commandand removedneeds-triageneeds to be reviewedneeds to be reviewed
on Feb 4, 2025
Describe the feature or problem you’d like to solve
As the title suggests, using the
--edit-lastflag forgh pr commentwill returnno comments found for the current userand failOne way to circumvent this is to check for existing comments and either comment if no comment already exists or
--edit-lastif one comment existsBut to me it'd make more sense for the flag to have the logic inside
Proposed solution
While this makes sense, what would possibly make more sense is to comment anyway if no comment is found, as this would be the first comment for the user, and then indeed it'll get edited in the future using the flag