diff --git a/.git-hooks/commit-msg b/.git-hooks/commit-msg deleted file mode 100755 index 45fd5c4..0000000 --- a/.git-hooks/commit-msg +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env bash - -if [ -z "$1" ]; then - echo "Missing argument (commit message). Did you try to run this manually?" - exit 1 -fi - -commitTitle="$(cat $1 | head -n1)" - -# ignore merge requests -if echo "$commitTitle" | grep -qE "Merge branch"; then - echo "Commit hook: ignoring branch merge" - exit 0 -fi - -# check semantic versioning scheme -if ! echo "$commitTitle" | grep -qE '^(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)\(.+\)!?: .+(\n\n.+)?(\n\nCloses #[0-9]{1,6})?$'; then - echo "Your commit title did not follow semantic versioning: $commitTitle" - echo "Please see https://github.com/angular/angular/blob/main/CONTRIBUTING.md#-commit-message-format" - exit 1 -fi diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..e198fac --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,28 @@ +default_install_hook_types: + - pre-commit + - commit-msg + - prepare-commit-msg + +default_stages: [pre-commit] + +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.2.0 + hooks: + - id: check-case-conflict + - id: check-merge-conflict + - id: trailing-whitespace + - id: mixed-line-ending + - id: end-of-file-fixer + - id: check-yaml + - id: check-json + - id: check-xml + - id: check-added-large-files + args: [ '--maxkb=50' ] + + - repo: https://github.com/compilerla/conventional-pre-commit + rev: v3.1.0 + hooks: + - id: conventional-pre-commit + stages: [ commit-msg ] + args: [ --strict ]