为git存储库强制执行常规git提交消息
enforce-git-message的Python项目详细描述
强制git消息
对通过运行git init
创建的所有新git存储库强制执行conventional git commit messages。对于现有的存储库,您可以转到源目录并简单地运行:< > >
enforce-git-message
有效的提交消息示例:
+ 61c8ca9 fix: navbar not responsive on mobile+ 479c48b test: prepared test cases for user authentication+ a992020 chore: moved to semantic versioning+ b818120 fix: button click even handler firing twice+ c6e9a97 fix: login page css+ dfdc715 feat(auth): added social login using twitter
导致错误消息的无效提交消息示例:
- 61c8ca9 fix for navbar not responsive on mobile- 479c48b prepared test cases for user authentication- a992020 moved to semantic versioning- b818120 fixed button click even handler firing twice- c6e9a97 login page css fix- dfdc715 added social login auth feature using twitter
安装
pip install enforce-git-message
验证
转到您的源文件夹并尝试使用这样的非常规消息提交,它应该会失败:
> git commit -m "added a new feature for xyz"
COMMIT FAILED!
Please enter commit message in the conventional format and try to commit again. Examples:
+ 61c8ca9 fix: navbar not responsive on mobile
+ 479c48b test: prepared test cases for user authentication
+ a992020 chore: moved to semantic versioning
+ b818120 fix: button click even handler firing twice
+ c6e9a97 fix: login page css
+ dfdc715 feat(auth): added social login using twitter
之后,尝试使用有效的消息执行提交,它应该可以工作:
> git commit -m "feat(test): added xyz"
>
注释
Read this article通过使用git钩子完全理解强制的实际工作方式。
归因
- 由smashicons从www.flaticon.com制作的勾号图标由CC 3.0 BY 授权