[tor-commits] [chutney/master] scripts/git: Add a pre-commit git hook

teor at torproject.org teor at torproject.org
Wed Feb 19 00:22:29 UTC 2020


commit 26ca33bb1fa990f57a7bb37371d0a98204f3edad
Author: teor <teor at torproject.org>
Date:   Mon Feb 17 16:16:21 2020 +1000

    scripts/git: Add a pre-commit git hook
    
    This git hook runs the shellcheck tests, and the unit tests.
    
    Part of 32792.
---
 scripts/git/pre-commit.git-hook | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/scripts/git/pre-commit.git-hook b/scripts/git/pre-commit.git-hook
new file mode 100755
index 0000000..9aa89d2
--- /dev/null
+++ b/scripts/git/pre-commit.git-hook
@@ -0,0 +1,21 @@
+#!/usr/bin/env bash
+#
+# To install this script, copy it to .git/hooks/pre-commit in local copy of
+# the chutney git repo, and make sure it has permission to execute.
+#
+# This is pre-commit git hook script that prevents commiting your changeset if
+# it fails our shellcheck or unit tests.
+
+workdir=$(git rev-parse --show-toplevel)
+
+cd "$workdir" || exit 1
+
+set -e
+
+if [ -e tests/shellcheck-tests.sh ]; then
+    tests/shellcheck-tests.sh
+fi
+
+if [ -e tests/unit-tests.sh ]; then
+    tests/unit-tests.sh
+fi





More information about the tor-commits mailing list