Pull Request Template
A Pull Request template is a standardized document that helps developers submit high-quality PRs. By providing a consistent format, the template allows team members to efficiently understand and review code changes. The following is a guide to creating and using GitCode Pull Request templates.
Creating a Pull Request Template
-
Select the template location:
You can place the PR template in the
.gitcode/
folder of the project (create it if it doesn't exist), or place it indocs/
or.gitcode/PULL_REQUEST_TEMPLATE/
, and create aPULL_REQUEST_TEMPLATE.md
file within it. You can create multiple template files in the.gitcode/PULL_REQUEST_TEMPLATE/
folder, and GitCode will display the created templates when a PR is created for this project.提示The template configuration must be placed in the default branch of the repository. If you create the template in another branch, the configuration will not take effect, and the related features will not be available for collaborative users.
-
Write the template content:
Write the content of the template in the
PULL_REQUEST_TEMPLATE.md
file. You can include some basic header information, problem description, change type, test instructions, and any additional notes or explanations. Ensure that you prompt contributors to provide all the information you believe is helpful for the review. You can configure front-matter information in the new.md
file, including the title of the PR template, the designated assignee, and the specified label. At the same time, add the main content in the new.md
file, which will be pre-filled into the description when users create a new PR.Example Template:
---
title: "【PR Template】:"
labels: ["fix","bug"]
assignees: 'username'
---
# Pull Request Template
----
## Description
Provide a high-level overview of this Pull Request.
## Type
- [ ] Bug Fix
- [ ] New Feature
- [ ] Code Style Update (Formatting, Local Variables)
- [ ] Refactor (i.e., code changes that are neither new features nor bug fixes)
- [ ] Changes to Build Processes or Auxiliary Tools
- [ ] Documentation Updates
## How to Test
Describe the steps to test this change, including which files need to be modified.
## Checklist:
- [ ] My code follows the style of this project
- [ ] I have tested my code myself
- [ ] I have updated the corresponding documentation
- [ ] I have updated the corresponding changelog as needed
- [ ] I have correctly used the type tag in the title (e.g., `feat:`, `fix:`)
## Additional Information
Add any additional notes related to this Pull Request here.
If you need to use a separator within the template, do not use three "-" symbols "----", to avoid conflicts with the separator symbols used in the template rules. It is recommended to use four "-" symbols "----".
-
Using the Template:
Once you have created the template, GitCode will automatically fill your template content into the PR description box when contributors create a Pull Request. Contributors should fill in all relevant information according to the template's prompts.
Introduction to Front-matter
We currently support the following types of markdown front-matter configurations:
Field | Description | Notes |
---|---|---|
titile | PR preset title | Use double quotes if containing Chinese |
labels | PR labels, supports multiple | Use square brackets for multiple, the label will not be displayed when creating a PR if it does not exist |
assignees | PR default assignee | The username of the person assigned to merge |
Notes
- Clarity: Ensure your template is clear and concise so that contributors can easily understand and follow it.
- Flexibility: Encourage contributors to follow the template, but also allow a certain degree of flexibility. Not every section needs to be filled by every contributor.
- Update and Maintenance: As the project develops, regularly update your template to ensure it remains relevant and continues to help you achieve your project goals.
By providing clear and well-organized Pull Request templates, you can improve the quality of your project, speed up the PR review process, and help contributors more effectively participate in the project.