# pre-commit
pre-commit stage 에 주의 해서 설치해야 한다.
`pre-commit install` 을 실행하면 `.git/hooks/pre-commit`이 생성된다.
`commit-msg`를 실행하고 싶다면, 해당 훅을 설치해야 한다.
pre-commit install --hook-type commit-msg
## hook-type
가능한 [[hook-type]] 목록
{pre-commit,pre-merge-commit,pre-push,prepare-commit-msg,commit-msg,post-checkout,post-commit,post-merge,post-rewrite}
기본은 [[pre-commit]]이다.((명령어와 같다.))
## 생성된 pre-commit
#!/usr/bin/env bash
# File generated by pre-commit: https://pre-commit.com
# ID: 138fd403232d2ddd5efb44317e38bf03
# start templated
INSTALL_PYTHON=/opt/homebrew/opt/python@3.9/bin/python3.9
ARGS=(hook-impl --config=.pre-commit-config.yaml --hook-type=pre-commit)
# end templated
HERE="$(cd "$(dirname "$0")" && pwd)"
ARGS+=(--hook-dir "$HERE" -- "$@")
if [ -x "$INSTALL_PYTHON" ]; then
exec "$INSTALL_PYTHON" -mpre_commit "${ARGS[@]}"
elif command -v pre-commit > /dev/null; then
exec pre-commit "${ARGS[@]}"
else
echo '`pre-commit` not found. Did you forget to activate your virtualenv?' 1>&2
exit 1
fi
## 생성된 commit-msg
#!/usr/bin/env bash
# File generated by pre-commit: https://pre-commit.com
# ID: 138fd403232d2ddd5efb44317e38bf03
# start templated
INSTALL_PYTHON=/opt/homebrew/opt/python@3.9/bin/python3.9
ARGS=(hook-impl --config=.pre-commit-config.yaml --hook-type=commit-msg)
# end templated
HERE="$(cd "$(dirname "$0")" && pwd)"
ARGS+=(--hook-dir "$HERE" -- "$@")
if [ -x "$INSTALL_PYTHON" ]; then
exec "$INSTALL_PYTHON" -mpre_commit "${ARGS[@]}"
elif command -v pre-commit > /dev/null; then
exec pre-commit "${ARGS[@]}"
else
echo '`pre-commit` not found. Did you forget to activate your virtualenv?' 1>&2
exit 1
fi
## github auto reference
![](https://i.imgur.com/wK3sOAR.png)
## .pre-commit-config.yaml
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
default_stages: [commit]
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- repo: local
hooks:
- id: jira-ticket-number-commit-msg
name: Appending jira ticket number to commit message
entry: bash -c 'bb --classpath hook --main prepare_commit_msg'
stages: [commit-msg]
language: system
- id: clj-kondo
name: Checking files with clj-kondo
entry: hook/clj-kondo.sh
stages: [push]
language: script