Skip to content

Instantly share code, notes, and snippets.

@snoe925
Last active July 1, 2019 20:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save snoe925/eba3b8c24085b6ed9141785fd696c07b to your computer and use it in GitHub Desktop.
Save snoe925/eba3b8c24085b6ed9141785fd696c07b to your computer and use it in GitHub Desktop.
#!/bin/sh
git config core.repositoryformatversion >/dev/null
if [ $? -ne 0 ]; then
echo "Not a git repository" >&2
exit 1
fi
if [ "$1" = "enable" ]; then
ORIGPATH=$PWD
# Back through (..) our full cwd until we find the repo base directory with .git/ in it.
while [ "$REPOPATH" = "" ] ; do
if [ -d .git ] ; then
REPOPATH=$PWD
elif [ "$PWD" = "/" ]; then
REPOPATH=/
else
cd ..
fi
done
HOOKFILE="$REPOPATH/.git/hooks/post-commit"
if [ ! -f "$HOOKFILE" ]; then
curl -s -L "https://raw.githubusercontent.com/flightaware/zeitgit/master/hooks/post-commit" >"$HOOKFILE"
chmod a+x "$HOOKFILE"
fi
git config zeitgit.enabled true
if [ "$2" != "" ]; then
git config zeitgit.receiveremail $2
else
git config zeitgit.receiveremail gitcommit@flightaware.com
fi
cd "$ORIGPATH"
elif [ "$1" = "disable" ]; then
git config zeitgit.enabled false
else
echo "Usage: `basename $0` enable [email@example.com]"
echo " `basename $0` disable"
exit 1
fi
echo "Zeitgit configuration:"
git config -l | grep -i zeitgit | sed 's/^/ /'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment