summaryrefslogtreecommitdiff
path: root/examples/pre-commit
diff options
context:
space:
mode:
Diffstat (limited to 'examples/pre-commit')
-rw-r--r--examples/pre-commit28
1 files changed, 17 insertions, 11 deletions
diff --git a/examples/pre-commit b/examples/pre-commit
index 1b5d5c6..b91635d 100644
--- a/examples/pre-commit
+++ b/examples/pre-commit
@@ -1,21 +1,27 @@
-#!/bin/bash
+#!/bin/sh
#
# An example hook script to store metadata information using
# metastore on each commit.
-if ! metastore -s; then
- echo "Failed to execute metastore -s" >&2
- exit 1
-fi
+MSFILE=".metadata"
-if [ ! -e ".metadata" ]; then
- echo ".metadata missing" >&2
- exit 1
-fi
+exit_on_fail() {
+ "$@"
+ if [ $? -ne 0 ]; then
+ echo "Failed to execute: $@" >&2
+ exit 1
+ fi
+}
+
+exit_on_fail \
+ metastore -s -f "$MSFILE"
-if ! git-add .metadata; then
- echo "Failed to execute git-add .metadata" >&2
+if [ ! -e "$MSFILE" ]; then
+ echo "\"$MSFILE\" missing" >&2
exit 1
fi
+exit_on_fail \
+ git-add "$MSFILE"
+
exit 0