open:pre-commit

pre-commit

pre-commit stage 에 주의 해서 설치해야 한다.

pre-commit install 을 실행하면 .git/hooks/pre-commit이 생성된다.

commit-msg를 실행하고 싶다면, 해당 훅을 설치해야 한다.

pre-commit install --hook-type commit-msg

가능한 hook-type 목록

{pre-commit,pre-merge-commit,pre-push,prepare-commit-msg,commit-msg,post-checkout,post-commit,post-merge,post-rewrite}

기본은 pre-commit이다.1)

#!/usr/bin/env bash
# File generated by pre-commit: https://pre-commit.com
# ID: 138fd403232d2ddd5efb44317e38bf03

# start templated
INSTALL_PYTHON=/opt/homebrew/opt/[email protected]/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

#!/usr/bin/env bash
# File generated by pre-commit: https://pre-commit.com
# ID: 138fd403232d2ddd5efb44317e38bf03

# start templated
INSTALL_PYTHON=/opt/homebrew/opt/[email protected]/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

# 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



1)
명령어와 같다.
  • open/pre-commit.txt
  • 마지막으로 수정됨: 2022/05/19 07:28
  • 저자 127.0.0.1