GitHub 代码规范管理:pre-commit 代码检查器 入门使用介绍/如何让每次git commit -m xxx 会自动检查代码格式和规范问题
GitHub 代码规范管理:pre-commit 代码检查器 入门使用介绍如何让每次git commit -m xxx 会自动检查代码格式和规范问题
·
GitHub 代码规范管理:pre-commit 代码检查器 入门使用介绍
如何让每次git commit -m xxx 会自动检查代码格式和规范问题
-
安装
pip install pre-commit
-
配置.yaml文件
在git项目的根目录创建一个.pre-commit-config.yaml 文件
例如:
# See https://pre-commit.com for more information # See https://pre-commit.com/hooks.html for more hooks repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v2.4.0 hooks: - id: check-xml - id: check-added-large-files - id: check-byte-order-marker - repo: https://gitlab.com/pycqa/flake8 rev: '3.7.9' hooks: - id: flake8 - repo: https://github.com/codespell-project/codespell rev: v1.16.0 hooks: - id: codespell
-
在终端执行下述命令
pre-commit install
-
即可实现,每次git commit -m xxxx 代码自动检查
具体检查统一的代码格式要求,可以在上述.yaml文件中设置
更多推荐
已为社区贡献2条内容
所有评论(0)