diff options
-rwxr-xr-x | debian/rules | 1 | ||||
-rw-r--r-- | examples/git-metapull | 49 | ||||
-rw-r--r-- | examples/pre-commit | 34 |
3 files changed, 84 insertions, 0 deletions
diff --git a/debian/rules b/debian/rules index 0d3cb37..b424dfc 100755 --- a/debian/rules +++ b/debian/rules @@ -46,6 +46,7 @@ binary-arch: build install dh_testroot dh_installchangelogs dh_installdocs + dh_installexamples examples/git-metapull examples/pre-commit dh_strip dh_compress dh_fixperms diff --git a/examples/git-metapull b/examples/git-metapull new file mode 100644 index 0000000..789149f --- /dev/null +++ b/examples/git-metapull @@ -0,0 +1,49 @@ +#!/bin/bash +# +# This script can be used instead of git-pull when updating a remote +# repo to make sure the metadata matches what is stored in the repo. +# It will do a git-pull, show a list of changes to be made to the metadata, +# and after getting confirmation, apply the changes. + +DO_MTIME=yes +umask 0077 + + +if ! git-pull; then + echo "Failed to execute git-pull" >&2 + exit 1 +fi + +if [ ! -e ".metadata" ]; then + echo ".metadata missing" >&2 + exit 1 +fi + +echo "Going to apply the following metadata changes" >&2 +if [ "$DO_MTIME" = "yes" ]; then + metastore -c -m >&2 +else + metastore -c >&2 +fi + +echo -n "Ok to apply? (y/n): " >&2 +read -n1 REPLY +echo "" + +if [ "$REPLY" != "y" ]; then + echo "Aborted" >&2 + exit 1 +fi + +if [ "$DO_MTIME" = "yes" ]; then + flags="-a -m" +else + flags="-a" +fi + +if ! metastore $flags; then + echo "Failed to execute metastore $flags" >&2 + exit 1 +fi + +exit 0 diff --git a/examples/pre-commit b/examples/pre-commit new file mode 100644 index 0000000..e0e89dd --- /dev/null +++ b/examples/pre-commit @@ -0,0 +1,34 @@ +#!/bin/bash +# +# An example hook script to store metadata information using +# metastore on each commit. A verification message with a list +# of changes will first be shown and only if it is accepted will +# the commit proceed. + +echo "Going to commit the following metadata changes" >&2 +metastore -c -m >&2 +echo -n "Ok to commit? (y/n): " >&2 +read -n1 REPLY +echo "" + +if [ "$REPLY" != "y" ]; then + echo "Aborted" >&2 + exit 1 +fi + +if ! metastore -s; then + echo "Failed to execute metastore -s" >&2 + exit 1 +fi + +if [ ! -e ".metadata" ]; then + echo ".metadata missing" >&2 + exit 1 +fi + +if ! git-add .metadata; then + echo "Failed to execute git-add .metadata" >&2 + exit 1 +fi + +exit 0 |