hhstore / blog

My Tech Blog: about Mojo / Rust / Golang / Python / Kotlin / Flutter / VueJS / Blockchain etc.
https://github.com/hhstore/blog/issues
291 stars 24 forks source link

Git Pro: git pre commit hook tool #248

Open hhstore opened 3 years ago

hhstore commented 3 years ago

related:

hhstore commented 3 years ago

Git Pre Commit Hook:

插件: pre-commit

安装:

# 安装:
brew install pre-commit

curl https://pre-commit.com/install-local.py | python -

# 检查版本: 
pre-commit --version

使用:


# 切换到项目根目录: 
cd project-root/

# 项目中激活: 
pre-commit install

配置文件:

hhstore commented 3 years ago

示例配置:

完整示例项目:

hhstore commented 3 years ago

用法示例:

配置好 git-pre-commit-hook 之后, 每次 git commit, 都会自动做 check, 如果check 不过, 无法提交代码.

image

commit check 不通过 提示 hook 插件, 帮你 fmt 了, 你要重新 commit 一次.

hhstore commented 3 years ago

1

hhstore commented 3 years ago

xxxxxx:

xxxxxxxxxxxxxx xxxxxxxxxxxxxx xxxx
xxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxx xxxxxxxxxx
xxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxx xxxxxxxxxx
xxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxx xxxxxxxxxx
xxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxx xxxxxxxxxx
xxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxx xxxxxxxxxx
xxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxx xxxxxxxxxx
xxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxx xxxxxxxxxx