feat: migrate and organize documentation and blog posts
refactor(blog): restructure blog post layouts and metadata docs: add markdown migration guide and project rules update style(global.css): update typography theme variables chore: move temp_docs to appropriate blog post locations
This commit is contained in:
132
temp_docs/git提交规范.md
Normal file
132
temp_docs/git提交规范.md
Normal file
@@ -0,0 +1,132 @@
|
||||
---
|
||||
id: git-commit-rules
|
||||
title: Git提交规范
|
||||
author: Joy Zhao
|
||||
sidebar_position: 2
|
||||
---
|
||||
|
||||
## commit message ( 三部分组成 )
|
||||
|
||||
### Header( 必需)
|
||||
|
||||
包括三个字段:
|
||||
|
||||
`type`(必需)
|
||||
|
||||
`scope`(可选)
|
||||
|
||||
`subject`(必需)
|
||||
|
||||
### **(1) type**
|
||||
|
||||
用于说明 commit 的类别,只允许使用下面7个标识:
|
||||
|
||||
- feat:新功能(feature)
|
||||
- fix:修补bug
|
||||
- docs:文档(documentation)
|
||||
- style: 格式(不影响代码运行的变动)
|
||||
- refactor:重构(即不是新增功能,也不是修改bug的代码变动)
|
||||
- test:增加测试
|
||||
- chore:构建过程或辅助工具的变动
|
||||
|
||||
### (2)scope
|
||||
|
||||
`scope`用于说明 commit 影响的范围,比如数据层、控制层、视图层等等,视项目不同而不同。
|
||||
|
||||
### (3)subject
|
||||
|
||||
`subject`是 commit 目的的简短描述,不超过50个字符。
|
||||
|
||||
- 以动词开头,使用第一人称现在时,比如`change`,而不是`changed`或`changes`
|
||||
- 第一个字母小写
|
||||
- 结尾不加句号(.`)`
|
||||
|
||||
### Body
|
||||
|
||||
Body 部分是对本次 commit 的详细描述,可以分成多行
|
||||
|
||||
例子:
|
||||
|
||||
````Plain
|
||||
|
||||
Further paragraphs come after blank lines.
|
||||
|
||||
- Bullet points are okay, too
|
||||
- Use a hanging indent ```
|
||||
|
||||
**注意点:**
|
||||
|
||||
1. 使用第一人称现在时,比如使用change而不是changed或changes。
|
||||
2. 应该说明代码变动的动机,以及与以前行为的对比。
|
||||
|
||||
### Footer
|
||||
|
||||
### Footer 部分只用于两种情况:
|
||||
|
||||
**(1)不兼容变动**
|
||||
|
||||
如果当前代码与上一个版本不兼容,则 Footer 部分以`BREAKING CHANGE`开头,后面是对变动的描述、以及变动理由和迁移方法。
|
||||
|
||||
```jsx
|
||||
Plain Text BREAKING CHANGE: isolate scope bindings definition has changed.
|
||||
To migrate the code follow the example below:
|
||||
|
||||
Before:
|
||||
|
||||
scope: {
|
||||
myAttr: 'attribute',
|
||||
}
|
||||
|
||||
After:
|
||||
|
||||
scope: {
|
||||
myAttr: '@',
|
||||
}
|
||||
|
||||
The removed `inject` wasn't generaly useful for directives so there should be no code using it.
|
||||
````
|
||||
|
||||
**(2)关闭 Issue**
|
||||
|
||||
如果当前 commit 针对某个issue,那么可以在 Footer 部分关闭这个 issue 。
|
||||
|
||||
```jsx
|
||||
Plain Text Closes #234
|
||||
|
||||
or
|
||||
|
||||
Closes #123, #245, #992
|
||||
```
|
||||
|
||||
### Revert ( 特殊情况 )
|
||||
|
||||
如果当前 commit 用于撤销以前的 commit,则必须以`revert:`开头,后面跟着被撤销 Commit 的 Header
|
||||
|
||||
```Plain
|
||||
|
||||
This reverts commit 667ecc1654a317a13331b17617d973392f415f02. ```
|
||||
|
||||
Body部分的格式是固定的,必须写成`This reverts commit <hash>.`,其中的`hash`是被撤销 commit 的 SHA 标识符。
|
||||
|
||||
如果当前 commit 与被撤销的 commit,在同一个发布(release)里面,那么它们都不会出现在 Change log 里面。如果两者在不同的发布,那么当前 commit,会出现在 Change log 的`Reverts`小标题下面
|
||||
|
||||
## 生成 Change log ( 三部分 )
|
||||
|
||||
需要所有 Commit 都符合 Angular 格式,Change log 就可以用脚本自动生成
|
||||
|
||||
- New features
|
||||
- Bug fixes
|
||||
- Breaking changes
|
||||
|
||||
每个部分都会罗列相关的 commit ,并且有指向这些 commit 的链接。当然,生成的文档允许手动修改,所以发布前,你还可以添加其他内容。
|
||||
|
||||
[conventional-changelog](<https://github.com/ajoslin/conventional-changelog>) 就是生成 Change log 的工具,运行下面的命令即可
|
||||
|
||||
## Commitizen
|
||||
|
||||
[Commitizen](<https://github.com/commitizen/cz-cli>)是一个撰写合格 Commit message 的工具
|
||||
|
||||
## validate-commit-msg
|
||||
|
||||
[validate-commit-msg](<https://github.com/kentcdodds/validate-commit-msg>) 用于检查 Node 项目的 Commit message 是否符合格式
|
||||
```
|
||||
Reference in New Issue
Block a user