aboutsummaryrefslogtreecommitdiff
path: root/hooks/pre-commit
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2020-02-05 21:18:18 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2020-02-06 13:51:59 +0300
commit754099b7218056a24d77aea0278bb3bc2c7a9716 (patch)
tree56ae541e000ebbb713a60e15465ce44eac01c274 /hooks/pre-commit
parent9ecee2a02b69c867962688f859cea4c8a7c28796 (diff)
Add pre-commit-copyright-check git hook
Diffstat (limited to 'hooks/pre-commit')
-rwxr-xr-xhooks/pre-commit26
1 files changed, 26 insertions, 0 deletions
diff --git a/hooks/pre-commit b/hooks/pre-commit
new file mode 100755
index 0000000..10a97d9
--- /dev/null
+++ b/hooks/pre-commit
@@ -0,0 +1,26 @@
+#! /usr/bin/env bash
+
+# Execute various pre-commit scripts in a git repository.
+#
+# To enable the hooks globally run:
+#
+# $ git config --global core.hooksPath <git-project-dir>/hooks
+#
+# Notes:
+#
+# - git passes no parameters to this kind of hooks.
+#
+# - git changes CWD to the git repository root directory for the hook process.
+#
+# - git command running from inside the hook sees files that should be
+# auto-staged due to the -a git-commit option or similar as already staged.
+#
+trap 'exit 1' ERR
+
+src_exe="$(realpath "${BASH_SOURCE[0]}")"
+src_dir="$(dirname "$src_exe")"
+
+# Run each hook checking the exit status and bailing out if unsuccessful. We
+# can just exec the last one.
+#
+exec "$src_dir/pre-commit-copyright-check"