1 Star 0 Fork 1.2K

kczhuang / LiteOS

forked from Huawei LiteOS / LiteOS 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
LiteOS_Commit_Message.md 3.08 KB
一键复制 编辑 原始数据 按行查看 历史
tinyfrog 提交于 2020-09-23 10:34 . update arch/kernel/lib

概要说明

目前,社区有多种 Commit message 的写法规范。LiteOS采用的是Angular规范,这是目前使用最广的写法,比较合理和系统化,并且有配套的工具。

Commit message的作用

格式化的Commit message有几个好处:

  • 提供更多的历史信息,方便快速浏览
  • 可以过滤某些commit(比如文档改动),便于快速查找信息
  • 可以直接从commit生成Change log

LiteOS Commit message的格式

每次提交,Commit message 都包括三个部分:Header,Body 和 Footer。

<header>
空一行
<body>
空一行
<footer>

比如:
fix(stm32f411): fix stm32f411 migration guide file error

fix some error in stm32f411re migration guide file.

Close #75

Header格式

Header部分只有一行,格式为:

<type>(<scope>): <subject>

Header部分共包括三个字段:type(必需)、scope(可选)和subject(必需)。

  • type

    type用于说明 commit 的类别,只允许使用下面7个标识。

     feat:feature的缩写,表示这是一个新功能
    
     fix:修补bug
    
     docs:documentation的缩写,表示修改的是文档
    
     style: 格式修改,是不影响代码运行的变动
    
     refactor:重构,它即不是新增功能,也不是修改bug
    
     test:增加测试
    
     chore:构建过程或辅助工具的变动
  • scope

    scope用于说明 commit 影响的范围,比如对LiteOS kernel的base的修改会影响全部代码,所以填写all。如果只修改stm32f411的代码,则填写stm32f411。

  • subject

    subject用于简短描述 commit 目的,不超过50个字符。

    • 以动词开头,使用第一人称现在时,比如change,而不是changed或changes
    • 第一个字母小写,结尾不加英文句号(.)

Body格式

Body 部分是对本次 commit 的详细描述,可以分成多行,下面是一个范例。

Add porting contest board projects to LiteOS
Board list:
Arduino-M0-PRO
ATSAM4S-XPRO
ATSAMD21-XPRO
EFM32-SLSTK3400A
EFM32-SLSTK3401A
EFM32-STK3700
FRDM-KL26Z
FRDM-KW41Z

有两个注意点:

  • 使用第一人称现在时,比如使用change而不是changed或changes。

  • 应该说明代码变动的动机,以及与以前行为的对比。

Footer格式

Footer 部分只用于两种情况。

  • 不兼容变动

如果当前代码与上一个版本不兼容,则 Footer 部分以BREAKING CHANGE开头,后面是对变动的描述、以及变动理由和迁移方法。

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.
  • 关闭 Issue

    如果当前 commit 针对某个issue,那么可以在 Footer 部分关闭这个 issue 。

Closes #16, #24, #92

更多参考

更详细的commit规则请参考原始的规范说明

Angular规范

C
1
https://gitee.com/kczhuang/LiteOS.git
git@gitee.com:kczhuang/LiteOS.git
kczhuang
LiteOS
LiteOS
master

搜索帮助