pre-commit
설치
python3 -m pip install pre-commit
commands
pre-commit install
- 기본적으로
~/.cache/pre-commit
위치에 사용할 모듈이 저장됩니다 PRE_COMMIT_HOME
를 선언하여 설치 위치를 변경할 수 있습니다
pre-commit init-templatedir <path>
git config init.templateDir
과 함께 사용하여 git init
이나 git clone
시 자동으로 pre-commit을 설치하도록 할 수 있습니다.
git config --global init.templateDir ~/.git-template
pre-commit init-templatedir ~/.git-template -t pre-commit -t prepare-commit-msg
Custom Hooks
ShellScript
.pre-commit-hooks.yaml
- id: <id> # .pre-commit-config.yaml에서 사용할 id 입니다
name: <name> # 실행될 때 표시될 이름입니다
entry: <relative-path> # 레포지토리의 root 기준으로 상대 경로를 적으면 됩니다
language: script
info
script 실행 시, 실행이 성공한 경우(exit 0
) stdout이 출력되지 않습니다.