Do you know the best way to suggest changes on a Pull Request?

Updated by Brady Stroud [SSW] 10 months ago. See history

123
<introEmbed body={<> Normally, the best way to provide feedback on content changes is to use the [change X to Y format](/change-from-x-to-y). When it comes to reviewing Pull Requests (PRs) in GitHub, this is not the case - it's inefficient for the PR owner. They have to manually interpret each suggested change, implement them in the code, and then commit the changes, which can be time-consuming. <introYoutube url="https://youtu.be/xSSz3vPDi4g" description="Video: Pull Request Suggestions | Brady Stroud | SSW Rules (4 min)" /> <imageEmbed alt="Image" size="large" showBorder={false} figureEmbed={{ preset: "badExample", figure: 'Bad example - GitHub - Using change X to Y format (need to copy+paste changes)', shouldDisplay: true }} src="/uploads/rules/pr-suggest-changes/bad-pr-suggest-changes.png" /> Instead, reviewers should use GitHub's **Add a suggestion** feature. This allows the reviewer to directly suggest changes in the code diff view, and the PR creator can easily accept or reject these changes with a single click. This process is more streamlined and makes it easier to implement suggestions. <imageEmbed alt="Image" size="large" showBorder={false} figureEmbed={{ preset: "goodExample", figure: 'Good example - GitHub - Using the \'Add a suggestion\' button', shouldDisplay: true }} src="/uploads/rules/pr-suggest-changes/good-suggest-a-change-button.png" /> </>} />

When the PR creator reviews the suggestion, they can either click 'Commit suggestion' to apply it directly or 'Resolve conversation' if they choose not to apply it.

Image

✅ Figure: Good example - GitHub - Easy to see what has changed + awesome 'Commit Suggestion' button ✨

If an author has made multiple suggestions to your code it may be best to add the suggestions in a batch and then. This allows you to create a single useful commit message that summarizes the changes in the feedback.

Image

✅ Figure: Good exmample - Applying code suggestions in a batch

Acknowledgements

Adam Cogan
Brady Stroud
Related rules

Need help?

SSW Consulting has over 30 years of experience developing awesome software solutions.