This page shows the source for this entry, with WebCore formatting language tags and attributes highlighted.

Title

PRs suck. Stop trying to fix them.

Description

I read through the article <a href="https://graphite.dev/blog/your-github-pr-workflow-is-slow" source="Graphite.Dev" author="">Your GitHub pull request workflow is slowing everyone down</a> with great interest because I, too, am not thrilled about how PRs work. While I agree with the problems Graphite see with PRs, I think they miss other problems---and I don't like their solution very much. <h>PRs are, apparently, HUGE</h> <bq>The single most important bottleneck is PR size - large PRs can make code reviews frustrating and ineffective. <b>The average PR on GitHub has 900+ lines of code changes.</b> For speed and quality, PRs should be maintained under 200 lines—with 50 lines being ideal. To put this in perspective, where giant <b>500+ line PRs take around 9 days to get merged on average, tiny PRs under 100 lines can make it from creation to landing within hours.</b></bq> Holy shit! The average is 900 lines? That's already using the system completely incorrectly. That's so wild. It absolutely confirms my theory that PRs are a terrible way of committing code. I already thought they were terrible just because of the limited UI and lack of introspection of what the code you're reviewing <i>actually does</i>. PRs don't encourage starting and running the change to verify that it actually works as advertised. You're not using any of the tools that you use to develop code to review it. How silly is that? If you load changes into an IDE, you can see how many warnings there are, see if the layout shifts when you format the document, etc. Why would you want to review in a completely different environment? As Robin Williams once eloquently put it, <a href="https://www.youtube.com/watch?v=iuanrhbAOxA" source="YouTube">It's like masturbating with an oven mitt.</a>. <img src="{att_link}prworkflow.png" href="{att_link}prworkflow.png" align="none" scale="50%"> Not only that, but people probably aren't looking at individual commits, so they're just reviewing 900+ lines at once. The fewer people there are looking at individual commits, the fewer people there will be who make good, individual commits. This is a shame because it would counteract the awfulness of reviewing code in the PR web-UI, at least a little bit. <h>PR web UIs are not good for reviews</h> There are far better and more efficient ways of reviewing code than with PR web UIs. Reviewing through a PR web UI should be a fallback that you only use when nothing else is possible. If you're in the same time zone and working on the same schedule as the rest of your team, there is absolutely no reason why you should you be using the PR web UI instead of real-time reviews of local commits. What the current PR machinery does is fool remote, async teams into thinking that they're reviewing code efficiently. A face-to-face, real-time review will be much more efficient and yield much higher-quality code. I honestly can't believe the high pain threshold that some developers have. If the developer hasn't pushed yet, then: <ol> Review with the person who wrote it. </ol> If the developer has pushed and is not available for real-time review, then: <ol> Pull. Open the branch in SmartGit. Examine the commits. Launch the solution/project. Run the tests locally. <div>Apply your own commits instead of review notes wherever possible. Yes, you can do this! Why not? You're both on the same team. It's a shared code base, not someone's personal zen garden. Instead of explaining what you would want changed, just make your suggestion in the form of a commit. It's often more efficient than writing prose.</div> Add review notes in SmartGit (synced with GitHub, Azure, GitLab, etc.) or use the PR Web UI to add review notes. </ol> You can thank me later. <h>Errors slip in</h> <bq><b>Problems can easily get hidden between the diffs, and reviewers often make assumptions instead of testing to avoid feeling overwhelmed.</b> One particularly interesting finding is that as the size of a PR increases (by number of files changed), the amount of time reviewers spend on each file decreases significantly (for PRs with 8 or more files changed).</bq> Obviously! But it's good to measure---this was my intuition. PRs don't encourage local testing or verification in an environment similar to that which the original developer used. <h>Dumbing down Git</h> <bq><b>By default, every PR is restricted to only 1 commit of <200 lines, keeping changes tightly scoped.</b> This forces developers to consciously limit work to related changes—the registration endpoint PR can't sneak in unrelated styling tweaks.</bq> Yikes! I don't like the sound of that. So you make multiple PRs rather than one PR with multiple smaller commits? Why don't you just review commits rather than one giant blob? Do you really need to corral each commit into its own branch and PR to force yourselves to actually make useful commits? Yeeess? 🧐 <bq>Stacking centers around breaking down big feature work into chains of smaller pull requests. Each PR is typically limited to 1 commit focused on an isolated change. <b>This restriction guides developers to consciously make only a single change, squashing and rebasing along the way, instead of cluttering the PR with random unnecessary commits like "typo fixes".</b></bq> This is yet another technique invented to accommodate teams that don't trust each other, or that contain people who, if they can't be trained to do better---or don't understand what better is---probably shouldn't be programming yet. Instead of teaching team members how to use their tools, they impose an arbitrary rule. What a kindergarten. <h>Integrate all the time!?</h> <bq>Unlike Git workflows, where it is easy to neglect staying updated, <b>Graphite centers your workflow around continually integrating with the current mainline state.</b></bq> Yikes! I don't love the sound of that, either. Doesn't that force you to spend more time on integration that you might have spent working? I understand you don't want to have long-lived branches, but now you're just shooting to the other extreme, forcing integration on every pull. It's not bad as long as the integrations are automatic, but might not be appropriate for developers who aren't great at resolving merge conflicts. Even if they know how to deal with them well, might they not waste time resolving conflicts integrating a version of their code that wasn't at all ready to be integrated? I understand that this feature follows from the logic of "if you integrate more often, then integration is easier," but, again, you're taking agency out of developers' hands, implicitly not trusting your team members. I don't like it. If you have several stacked commits, I wonder how much shuffling there is in the working tree (causing unwanted IDE reloads) during the integration cascade. Are they somehow integrating without touching the working tree? I don't know that that's possible. Go ahead and work on the main branch if you want---I do it all the time---but this should be more of a choice than it sounds like it is. <h>I remember this...</h> <bq><b>This command will add your changes and create a new branch in one motion.</b> You can then continue iterating by creating and stacking additional branches:</bq> Ah, I see now. They've reinvented <a href="https://wiki.mercurial-scm.org/MqTutorial">Mercurial's patch queues</a>. Everything old is new again. A really bright and good friend of mine <a href="https://arrenbrecht.ch/mercurial/pbranch/intro.htm">added an extension to Mercurial's <c>mq</c></a> decades ago that sounds like it works the same. I remember discussing the technique with him as he was developing it. <h>Conclusion</h> I'm a bit worried about two things: <ol> The one-commit-per-branch thing The auto-integration-cascade </ol> <bq>By cleaning up your PR commit history, you ensure a clear and concise main branch history that makes it easy to see exactly what’s changed over time.</bq> By enforcing one commit per branch, you dumb everything down. It does seem that, instead of acknowledging that PR supremacy is stupid, Graphite doubles down, strips branches of most of their functionality by equating them to commits, and uses multiple PRs to force people to review by commit. It seems like a waste. But, hey, maybe I need to actually try it. I might be missing something. Still, instead of adding another tool, I think you should use git <i>better</i>. <ul> Set up your local tools---or in-cloud IDEs, whatever---to support building the kind of code you want. See <a href="{app}/view_article.php?id=4897">How to replace “warnings as errors” in your process</a> for more information. Encourage your team members to learn how to use those tools. Have a review culture centered on real-time reviews where quick fixes and changes can be made before you've even pushed anything. This cultivates a culture of respect for commits. Use PRs only to "stamp" a set of changes and merge them to the trunk. </ul>