Pull-Request Review

Layers of Management ThoughtLayer 10: Practices and RitualsPracticeAlso known as Pull request, Merge request review, PR review

A practice of Git-based software teams with no single author: GitHub added pull requests in February 2008 as a way to ask another developer to pull a branch, and rebuilt them in August 2010 as a discussion around the proposed change, its own take on code review.

Requires every proposed change to a shared code base to be described, checked by machines, and read and approved by another engineer before it merges, with the discussion kept beside the code it changed.

The pull request behind the double charges, replayed, and the four moves that decide whether its review is real and quick

The request that caused the double charges, replayed under the team's new rules. At each turn, pick the move for the author or the reviewer: one keeps the review careful and quick, the other turns it into a stamp or a queue. The line under the panel counts the moves that do both. Illustrative.

Author

Reviewer

Author

Reviewer

Select a stage to read it, or play the sequence.Size. A developer has added automatic retries to the payment service and tidied the payment module on the way. Pick how she opens the request.Pick a move to see the reply.The reviewer skims it in fourteen minutes and approves.Too big to read, so the review becomes a stamp.The reviewer can read the retry logic line by line in one sitting.Small enough to review with care.Description. Pick what the author writes in the description.Pick a move to see the reply.The reviewer has to rebuild what changed and why from the diff.Understanding, the hardest part of review, left to guesswork.The reviewer checks the reasoning in minutes.The author supplies the understanding review depends on.First look. Automated tests pass within ten minutes. Pick what the reviewer does.Pick a move to see the reply.Retries fire after a timeout even when the first charge went through, and some customers are charged twice.A stamp: nobody read the logic.The author finds the gap, checks for an existing charge before any retry, and adds a test for it.A defect caught before any customer meets it.Revision. The author pushes the revision with its new test, and the checks run again and pass.Style. The revision uses a naming style the reviewer dislikes. Pick the reviewer's move.Pick a move to see the reply.The change waits two more days while the two argue.Review time spent on what a formatter could settle.The change merges the same afternoon.Careful where it matters, quick everywhere else.Merge. The retries ship that evening without a double charge, and the tidying follows as two small requests during the week.

Moves that keep review careful and quick: 0 of 4Moves that keep review careful and quick: 1 of 4Moves that keep review careful and quick: 2 of 4Moves that keep review careful and quick: 3 of 4Moves that keep review careful and quick: 4 of 4

  1. Size (Author). A developer has added automatic retries to the payment service and tidied the payment module on the way. Pick how she opens the request.
    • Open one request with the retries and the tidying together: 1,100 lines. The reviewer skims it in fourteen minutes and approves. Too big to read, so the review becomes a stamp.
    • Split it: the retries and their tests first, 160 lines, and the tidying in later requests. The reviewer can read the retry logic line by line in one sitting. Small enough to review with care.
  2. Description (Author). Pick what the author writes in the description.
    • A title only: Add payment retries. The reviewer has to rebuild what changed and why from the diff. Understanding, the hardest part of review, left to guesswork.
    • What the retry does, when it fires, and how the tests show it. The reviewer checks the reasoning in minutes. The author supplies the understanding review depends on.
  3. First look (Reviewer). Automated tests pass within ten minutes. Pick what the reviewer does.
    • Approve at once, since the tests pass. Retries fire after a timeout even when the first charge went through, and some customers are charged twice. A stamp: nobody read the logic.
    • Read it and ask what happens if the provider times out after taking the charge. The author finds the gap, checks for an existing charge before any retry, and adds a test for it. A defect caught before any customer meets it.
  4. Revision (Author). The author pushes the revision with its new test, and the checks run again and pass.
  5. Style (Reviewer). The revision uses a naming style the reviewer dislikes. Pick the reviewer's move.
    • Hold the merge until the names and brace placement suit the reviewer. The change waits two more days while the two argue. Review time spent on what a formatter could settle.
    • Leave style to the formatter and approve now that the duplicate case is covered. The change merges the same afternoon. Careful where it matters, quick everywhere else.
  6. Merge (Author). The retries ship that evening without a double charge, and the tidying follows as two small requests during the week.

An example

At an online grocery delivery company, a bug charged some customers twice, and the incident review traced it to a pull request of 1,100 lines approved fourteen minutes after it was opened. The team's requests averaged 900 lines and waited almost two days for a first review, and busy reviewers approved the big ones on trust.

The engineering manager changed four rules. Requests stayed under 400 lines, with larger work split behind feature flags. Every description stated what changed, why, and how it was tested. Automated tests and a formatter ran before any person looked. And someone on the team picked up each request within four working hours. Within a quarter, requests averaged 250 lines and merged about five hours after opening. Reviewers left more comments per request, most of them about logic and missing cases and almost none about style, and the defects reaching customers fell by half.

The core idea

A pull request is a proposal to merge a set of changes from one branch of a code base into another, usually the shared main line. Pull-request review is the practice of having at least one other engineer examine and approve that proposal first. It happens in a tool and at each person's own pace: the author describes the change, automated checks run, reviewers comment on specific lines, the author revises, and an approval allows the merge. Every step is written down, so the reasoning stays attached to the code.

The practice puts a gate between writing code and shipping it, and two quantities decide whether the gate helps. Size: a reviewer can read a few hundred lines with care, and past that the reading turns into a glance. Waiting: a request that sits for days blocks its author, breeds merge conflicts, and tempts reviewers to approve unread. Small, clearly described requests picked up within hours keep both the quality and the flow.

The thinking behind it

Git and GitHub software practice Git, built by the Linux kernel's developers in 2005, kept changes on branches and gave contributors a command that asks an upstream project to pull their work. GitHub turned that request into a feature in February 2008, a simple message telling another developer to pull a branch. In August 2010 it rebuilt them around a running discussion of the proposed change and presented them as its approach to code review. By then users had sent some 200,000 of them. A 2013 study of review at Microsoft found what teams get from the habit: finding defects is the reason people give, while much of the value arrives as shared knowledge and better alternatives.

Where it sits in the layers

Pull-request review is a practice of Layer 10, where a software organization's ideas about quality meet every change it makes. It puts to work Continuous Delivery and Trunk-Based Development from Layer 6, which need changes small and frequent enough to merge daily, and it is the everyday form of the review that DevOps in Layer 8 builds into the delivery pipeline. Beside it in Layer 10, Code Review is the wider discipline it belongs to. The common mistake is asking the review to be the whole quality system. Reviewers catch some defects and miss many, so a team that leans on approvals in place of automated tests and monitoring ships defects with signatures attached. Design choices also belong in a conversation before the code exists, because a finished pull request is a costly place to reject an approach.

How organizations put it to work

Pull-request review is owned by the engineering team, with an engineering manager or technical lead setting the rules and a platform team running the tooling. Adoption settles a handful of standards. Every change to the main line goes through a request, with at least one approval, and two for sensitive code such as payments or security. A size limit or a firm norm keeps requests small, a template shapes each description, and automated tests, linting, and formatting run before any person looks. A target sets how soon the first review starts, usually within a working day. Ownership files route each request to the people who know that part of the code.

The measures are time from opening to merge, time to first review, request size, and defects that reach production. Review load has to be spread across the team, since a senior engineer who reviews everything becomes both the bottleneck and the single holder of knowledge.

In the first year, expect friction over size limits and a dip in individual output, offset by faster merges, fewer escaped defects, and more engineers who know each part of the system. The last of these matters most: a code base many people have read survives the departure of any one of them.

Where it goes wrong

The first failure is the rubber stamp. Large requests are approved within minutes because nobody has time to read them. Spot it when approval time does not grow with request size, or when thousand-line changes pass without a comment.

The second is the queue. Requests wait days for a first look, authors start new work and lose the thread, and branches drift into conflicts. Spot it when the wait for a first review is longer than the time it took to write the change.

The third is review as gatekeeping. Reviewers block on personal style or reopen settled design, and authors learn to route around certain reviewers. Spot it when most comments concern formatting or naming. The Microsoft research adds a caution for every team: reviews find fewer defects than people expect, so much of their value lies in shared understanding of the code.

Related and rival frameworks

  • Code Review. The wider discipline of peers examining code, from formal inspections to informal reading. Pull-request review is its asynchronous, tool-based form.
  • Pair Programming. Reviews every line as it is written, by a second engineer at the same screen. Better for hard or risky code, where a later review comes too late.
  • Trunk-Based Development. Merges small changes into the main line at least daily, which sets the pace pull-request review has to keep.

Go to the source

Back to the catalog