使用此模板撰写更好的 PR 📄

2025-06-07

使用此模板撰写更好的 PR 📄

嘿!

所以,最近我开始在一家新公司工作,其中审查代码的过程并不是工作流程的关键部分,所以我正在为我们的拉取请求开发一个模板,试图改进我们的代码库和审查新更改的过程。

我为什么要这么做?真的有必要吗?

是的。我认为拉取请求应该是一种文档,你可以向同事解释你修改的内容,不是解释代码,而是解释这个修改背后的业务逻辑,以及你为什么要做这项工作?

因此我为此创建了一个模板,并在每次想要创建新 PR 时将其设置为默认模板。

模板如下:

Context

Gives the reviewer some context about the work and why this change is being made, the WHY you are doing this. This field goes more into the product perspective.

Description

Provide a detailed description of how exactly this task will be accomplished. This can be something technical. What specific steps will be taken to achieve the goal? This should include details on service integration, job logic, implementation, etc.

Changes in the codebase

This is where becomes technical. Here is where you can be more focused on the engineering side of your solution. Include information about the functionality they are adding or modifying, as well as any refactoring or improvement of existing code.

Changes outside the codebase

If you have made changes to external services, need to add additional values to the job settings, or need to add something new to the database, explain it here. This may include updates to third-party services, changes to infrastructure configuration, integration with external APIs, etc.

Aditional information

Provide any additional information that might be useful to the reviewer in evaluating this pull request. This could include performance considerations,design choices, etc.

view raw pr_template.md hosted with ❤ by GitHub

在 Github 中添加模板为默认模板

如果您使用 Github,将其作为 PR 模板非常容易,您只需创建一个名为的文件pull_request_template.md并将其放在项目的根目录中或.github文件夹内。

您可以在此处查看更多详细信息:https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/creating-a-pull-request-template-for-your-repository

就这样吧,希望可以对你有帮助🥳

文章来源:https://dev.to/nicolasmontielf/writing-a-good-pull-request-with-template-46pm
PREV
我根本不使用 JavaScript 类。我是不是错过了什么?
NEXT
使用 Vite 和 Typescript 创建 React 组件库