diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml new file mode 100644 index 000000000..d0c315ffc --- /dev/null +++ b/.pre-commit-hooks.yaml @@ -0,0 +1,20 @@ +# expected stages: commit, commit-msg, manual, merge-commit, post-checkout, post-commit, post-merge, post-rewrite, prepare-commit-msg, push + + - id: check-doorstop-errors + args: ["-W"] + name: check for doorstop errors + description: ensures the changes introduces no errors + entry: doorstop + language: python + verbose: true + pass_filenames: false + stages: [commit, push, manual] + + - id: check-unreviewed-items + name: ensure that all requirements are reviewed before being committed + description: ensure that all documents/requirements are reviewed before being committed + entry: git_hooks/check_unreviewed_requirements.sh + language: script + verbose: true + pass_filenames: false + stages: [merge-commit, manual] diff --git a/git_hooks/check_unreviewed_requirements.sh b/git_hooks/check_unreviewed_requirements.sh new file mode 100755 index 000000000..c94069797 --- /dev/null +++ b/git_hooks/check_unreviewed_requirements.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +output="$(doorstop -W 2>&1 | grep 'unreviewed changes')" + +if [ -n "$output" ]; then + echo "$output" + exit 1 +fi diff --git a/pyproject.toml b/pyproject.toml index d0cd6264d..e5f84d51b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -108,4 +108,4 @@ profile = "black" [build-system] requires = ["poetry>=0.12"] -build-backend = "poetry.masonry.api" +build-backend = "poetry.core.masonry.api"