Pull Requests
Tip
We Use Github Flow, so All Code Changes Happen Through Pull Requests
Our development process is as follows:
- Make a fork.
- Create a branch on your fork, do not develop on main.
- Create a pull request as soon as you want others to be able to see your progress, comment, and/or help:
- Err on the side of creating the pull request too early instead of too late. Having an active PR makes your work visible, allows others to help you and give feedback. Request reviews from people who have worked on similar parts of the project.
- Keep the PR in draft status until you think it’s ready to be merged.
- Assign PR to reviewer(s) when it’s ready to be merged.
- Only Oz (@ozgurakgun) can merge PRs, so add him as a reviewer when you want your PR to be merged.
- During reviewing, avoid force-pushing to the pull request, as this makes reviewing more difficult. Details on how to update a PR are given below.
- Once Oz has approved the PR:
- Update your PR to main by rebase or merge. This can be done through the Github UI or locally.
- Cleanup your git history (see below) or request your PR to be squash merged.
Style
- Run
cargo fmtin the project directory to automatically format code - Use
cargo clippyto lint the code and identify any common issues
See: [[Documentation Style]] and [[Rust Coding Style]] (TODO)
Commit and PR Titles
We use Semantic PR / Commit messages.
Format: <type>(<scope>): <subject>
(<scope> is optional)
Example
feat(parser): add letting statements
^--^ ^----^ ^--------------------^
| | |
| | +--> Summary in present tense.
| |
| +--> Area of the project affected by the change.
|
+-------> Type: chore, docs, feat, fix, refactor, style, or test.
Types
feat: new features for the end userchore: changes to build scripts, CI, dependency updates; does not affect production codefix: fixing bugs in production codestyle: purely stylistic changes to the code (e.g. indentation, semicolons, etc) that do not affect behaviourrefactor: changes of production code that do not add new features or fix specific bugstest: adding, updating, or refactoring test codedoc: adding or updating documentation
PR Messages
Your pull request should contain a brief description explaining:
- What changes you are making
- Why they are necessary
- Any significant changes that may break other people’s work
Additionally, you can link your PR to an issue. For example: closes issue #42.
Amending your PR and Force Pushes
You should avoid rebasing, amending, and force-pushing changes during PR review. This makes code review difficult by removing the context around code review comments and changes to a commit.
The recommended way to update PRs is to use git’s built-in support for fixups.
To make a change to a commit (e.g. addressing a code review comment):
git commit --fixup <commit>
git push
Once your PR is ready to merge, these fixup commits can be merged into their original commits like so:
git rebase --autosquash main
git push --force
We have CI checks to block accidental merging of fixup! commits.
See:
- https://rietta.com/blog/git-rebase-autosquash-code-reviews/
- https://git-scm.com/docs/git-commit#Documentation/git-commit.txt—fixupamendrewordltcommitgt
Before your PR is merged
When your PR is approved, you may need to rebase your branch onto main before it can be merged. Rebasing essentially adds all the latest commits from main to your branch if it has fallen behind main.
To do this:
- Make sure that your
mainbranch is synced to the main repo - Switch to the branch you’re making the PR from
- Do:
git rebase main git push --force
(Optional) Cleaning up your Git history
Additionally, if you are proficient with git, you can use interactive rebase to clean up your commit history. This allows you to reorder, drop, or amend commits arbitrarily.
See:
There are some GUI tools to help you do that, such as the GitHub Client, GitKraken, various VS Code extensions, etc.
Warning
Interactive rebase and force-pushing overwrites your git history, so it can be destructive. This is also not a requirement!
Squashing PRs
Alternatively, you can ask for the PR to be “squashed”. This combines all your commits into one merge commit. Squashing PRs helps keep the commit history on main clean and logical without requiring you to go back and manually edit your commits!