sourcery icon indicating copy to clipboard operation
sourcery copied to clipboard

Have the GitHub app do code reviews instead of separate PRs

Open br3ndonland opened this issue 3 years ago • 2 comments

Currently, Sourcery suggests refactorings by opening a separate PR, which will be merged into the original PR. All the refactorings are performed in a single commit, so if you want to reject one, you have to manually modify the code and push another commit. And there are some instances in which Sourcery will open multiple PRs (sourcery-ai/sourcery#223), which is probably unnecessary.

Instead, could the GitHub app perform a code review in the original PR? There would be some benefits to this:

  • The Sourcery GitHub app wouldn't need to manage its own separate PRs
  • Individual refactorings could be accepted or rejected on a line-by-line basis, by using the "commit suggestion" feature

I think the app is nearly there already - it shows the diff after the proposed change, and makes comments explaining why. It would just be a matter of moving that functionality into the pull request review API.

What do you think?

Related:

br3ndonland avatar Apr 11 '22 21:04 br3ndonland

This is indeed a great idea, and something we will look into in the next stages of our roadmap. Thanks for bringing this up!

How do you think this should work for "bulk accepts"? One advantage of having PRs instead of code reviews is that one can simply merge the Sourcery PR and have all changes merged, as opposed to having to manually accept each commit suggestion separately - with the downside that it gets harder to reject some of the changes.

ruancomelli avatar Apr 12 '22 13:04 ruancomelli

How do you think this should work for "bulk accepts"? One advantage of having PRs instead of code reviews is that one can simply merge the Sourcery PR and have all changes merged, as opposed to having to manually accept each commit suggestion separately - with the downside that it gets harder to reject some of the changes.

Yeah, this is an important consideration. Thankfully GitHub has a "batch" feature, as they describe in the docs. You can add multiple suggestions to a "batch," then commit them all at the same time.

br3ndonland avatar Apr 12 '22 23:04 br3ndonland