Pull Requests and Code Review
A pull request (PR) asks to merge a branch. It shows the diff, runs automated checks and collects review comments. Even solo developers benefit: the PR is a checklist and a record of why each change happened.
The flow
git switch -c feature/invoices- Commit in small, logical steps.
git push -u origin feature/invoices- Open the PR on GitHub with a clear description.
- Automated tests run (GitHub Actions, covered in Automation & Scripting).
- Review, discuss, push fixes to the same branch.
- Merge, delete the branch, pull
mainlocally.
A good PR description
## What
Adds PDF invoices for contract payments.
## Why
Clients asked for downloadable invoices for their accounts.
## How to test
1. Pay a test contract with card 4242 4242 4242 4242
2. Open Account → Payments → Invoice
## Notes
Amounts use to_minor_units so JPY is not multiplied by 100.
Keep PRs small
A 50-line PR gets a careful review in minutes. A 2,000-line PR gets "looks good to me" and hides bugs. Split big work into steps that each leave the app working.
Reviewing well
- Check behaviour first: does it do what the description says? Are edge cases handled?
- Then security: input validation, permissions, secrets, SQL built from strings.
- Then clarity: names, duplication, tests.
- Ask questions instead of giving orders: "What happens if
amountis empty?" - Approve when it is good enough and safe, not when it matches your personal style.
Merge strategies
| Strategy | Result |
|---|---|
| Merge commit | keeps every commit plus a merge commit |
| Squash and merge | the whole PR becomes one commit on main |
| Rebase and merge | commits replayed linearly on main |
Squash keeps main readable when branches contain many small "wip" commits.
Protecting main
In Settings → Branches, add a rule for main: require a pull request, require status checks to pass, and block force pushes. Now nothing reaches production without tests passing.
Check yourself
- What four things belong in a PR description?
- Why are small PRs reviewed better?
- Which branch protection settings stop untested code reaching main?
Tu progreso se guarda solo en este navegador.
Enviar para revisión (10 puntos)