Skip to content

Instantly share code, notes, and snippets.

@snoe925 snoe925/zeitgit
Created May 15, 2019

Embed
What would you like to do?
#!/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
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
You can’t perform that action at this time.