2021-08-09 22:29:21 +08:00
## Pull Request (PR)
### What is PR
`PR` is the abbreviation of `Pull Request` . Here's the definition of `PR` in the [official document ](https://docs.github.com/en/github/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests ) of Github.
2021-12-09 11:03:08 +08:00
```
Pull requests let you tell others about changes you have pushed to a branch in a repository on GitHub. Once a pull request is opened, you can discuss and review the potential changes with collaborators and add follow-up commits before your changes are merged into the base branch.
```
2021-08-09 22:29:21 +08:00
2021-08-19 10:04:54 +08:00
### Basic Workflow
2021-08-09 22:29:21 +08:00
1. Get the most recent codebase
2. Checkout a new branch from the master branch
3. Commit your changes
4. Push your changes and create a PR
5. Discuss and review your code
6. Merge your branch to the master branch
### Procedures in detail
2021-12-09 11:03:08 +08:00
#### 1. Get the most recent codebase
2022-05-16 20:47:56 +08:00
- When you work on your first PR
2021-12-09 11:03:08 +08:00
Fork the OpenMMLab repository: click the **fork** button at the top right corner of Github page
2022-05-16 20:47:56 +08:00

2021-12-09 11:03:08 +08:00
Clone forked repository to local
```bash
git clone git@github.com:XXX/mmcv.git
```
Add source repository to upstream
```bash
git remote add upstream git@github.com:open-mmlab/mmcv
```
2022-05-16 20:47:56 +08:00
- After your first PR
2021-12-09 11:03:08 +08:00
2022-05-16 20:47:56 +08:00
Checkout master branch of the local repository and pull the latest master branch of the source repository
2021-08-09 22:29:21 +08:00
2022-05-16 20:47:56 +08:00
```bash
git checkout master
git pull upstream master
```
2021-08-09 22:29:21 +08:00
2021-12-09 11:03:08 +08:00
#### 2. Checkout a new branch from the master branch
```bash
git checkout -b branchname
```
2021-08-22 09:44:51 +08:00
```{tip}
To make commit history clear, we strongly recommend you checkout the master branch before create a new branch.
```
2021-08-09 22:29:21 +08:00
2021-12-09 11:03:08 +08:00
#### 3. Commit your changes
```bash
# coding
git add [files]
git commit -m 'messages'
```
#### 4. Push your changes to the forked repository and create a PR
2022-05-16 20:47:56 +08:00
- Push the branch to your forked remote repository
2021-12-09 11:03:08 +08:00
2022-05-16 20:47:56 +08:00
```bash
git push origin branchname
```
2021-08-09 22:29:21 +08:00
2022-05-16 20:47:56 +08:00
- Create a PR

2021-08-09 22:29:21 +08:00
2022-05-16 20:47:56 +08:00
- Revise PR message template to describe your motivation and modifications made in this PR. You can also link the related issue to the PR manually in the PR message (For more information, checkout the [official guidance ](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue )).
2021-08-09 22:29:21 +08:00
2021-12-09 11:03:08 +08:00
#### 5. Discuss and review your code
2021-08-09 22:29:21 +08:00
2022-05-16 20:47:56 +08:00
- After creating a pull request, you can ask a specific person to review the changes you've proposed

2021-08-09 22:29:21 +08:00
2022-05-16 20:47:56 +08:00
- Modify your codes according to reviewers' suggestions and then push your changes
2021-08-09 22:29:21 +08:00
2021-12-09 11:03:08 +08:00
#### 6. Merge your branch to the master branch and delete the branch
```bash
git branch -d branchname # delete local branch
git push origin --delete branchname # delete remote branch
```
2021-08-09 22:29:21 +08:00
### PR Specs
1. Use [pre-commit ](https://pre-commit.com ) hook to avoid issues of code style
2021-12-09 11:03:08 +08:00
2021-08-09 22:29:21 +08:00
2. One short-time branch should be matched with only one PR
2021-12-09 11:03:08 +08:00
2021-08-09 22:29:21 +08:00
3. Accomplish a detailed change in one PR. Avoid large PR
2021-12-09 11:03:08 +08:00
2022-05-16 20:47:56 +08:00
- Bad: Support Faster R-CNN
- Acceptable: Add a box head to Faster R-CNN
- Good: Add a parameter to box head to support custom conv-layer number
2021-12-09 11:03:08 +08:00
2021-08-09 22:29:21 +08:00
4. Provide clear and significant commit message
2021-12-09 11:03:08 +08:00
2021-08-09 22:29:21 +08:00
5. Provide clear and meaningful PR description
2021-12-09 11:03:08 +08:00
2022-05-16 20:47:56 +08:00
- Task name should be clarified in title. The general format is: \[Prefix\] Short description of the PR (Suffix)
- Prefix: add new feature \[Feature\], fix bug \[Fix\], related to documents \[Docs\], in developing \[WIP\] (which will not be reviewed temporarily)
- Introduce main changes, results and influences on other modules in short description
- Associate related issues and pull requests with a milestone