summaryrefslogtreecommitdiff
path: root/examples/hooks/pre-commit
diff options
context:
space:
mode:
authorPrzemyslaw Pawelczyk <przemoc@gmail.com>2016-01-19 20:42:22 +0100
committerPrzemyslaw Pawelczyk <przemoc@gmail.com>2016-01-19 20:42:22 +0100
commitd119c8d1f5b18c6ee9c5efa90615427083875e00 (patch)
treed503ac20083e98e84e6a4cb33f021ce2d03621b0 /examples/hooks/pre-commit
parentd2924f4f2f606d36ac123162c079335ce275f742 (diff)
examples: Move hook scripts to their own subdirectory.
Diffstat (limited to 'examples/hooks/pre-commit')
-rw-r--r--examples/hooks/pre-commit27
1 files changed, 27 insertions, 0 deletions
diff --git a/examples/hooks/pre-commit b/examples/hooks/pre-commit
new file mode 100644
index 0000000..b91635d
--- /dev/null
+++ b/examples/hooks/pre-commit
@@ -0,0 +1,27 @@
+#!/bin/sh
+#
+# An example hook script to store metadata information using
+# metastore on each commit.
+
+MSFILE=".metadata"
+
+exit_on_fail() {
+ "$@"
+ if [ $? -ne 0 ]; then
+ echo "Failed to execute: $@" >&2
+ exit 1
+ fi
+}
+
+exit_on_fail \
+ metastore -s -f "$MSFILE"
+
+if [ ! -e "$MSFILE" ]; then
+ echo "\"$MSFILE\" missing" >&2
+ exit 1
+fi
+
+exit_on_fail \
+ git-add "$MSFILE"
+
+exit 0