Skip to content

Submit a suggested change to a PR from the Github CLI #5905

@sfullerbeckman

Description

@sfullerbeckman

Discussed in #5904

Originally posted by sfullerbeckman July 8, 2022

You know...

Have you used the "Add a suggestion" button when sumbmitting feedback to a PR? This allows reviewers to submit changes that can be committed directly to the PR branch. This is a great feature and can make it easier for users to collaborate on a PR and saves time, especially if a reviewer already knows how to fix an issue in the PR and can provide a commitable piece of code to the PR.

What if...

But what if we could submit changes to a PR through gh cli? Imagine checking out someone's code with gh pr checkout [pr number]. Then you could look at the person's PR in any IDE or text editor that you wish on your local machine. If you want to submit a suggestion, you would do so directly in your editor. These diff-able changes would be picked up by git of course. But instead of committing those changes directly to the person's PR (which you wouldn't want to do; your code is just a suggestion), you could run a command such as gh pr suggest [pr number]. The cli would pick up staged but uncommited changes and push them directly to the PR as a comment with "suggest changes" that could be directly applied to the PR.

How...

Essentially the process would be...

  1. gh pr checkout [pr number]
  2. Makes some changes to the code in your editor
  3. git add -A
  4. gh pr suggest [pr number]

Why...

Two of the main benefits of a feature like this are as follows:

  1. Someone can do an entire review from their local machine on their own familiar editor: review code, add comments, submit suggestions, etc. No longer would you have to context switch between the browser and their local editor.
  2. By reviewing in the editor, you have all the build tools and static anlysis tools available to you inherantly. The reviewer would now have more confidence in the code he submits to the PR. He can confirm that the suggestion compiles and runs properly.

gh already gives you the ability to review and add comments to PRs. My suggested feature would streamline the proccess of reviewing and submitting suggestions to the PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    coreThis issue is not accepting PRs from outside contributorsenhancementa request to improve CLIgh-prrelating to the gh pr command

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions