Skip to content

Instantly share code, notes, and snippets.

@waffle2k
Created October 28, 2011 19:54
Show Gist options
  • Save waffle2k/1323372 to your computer and use it in GitHub Desktop.
Save waffle2k/1323372 to your computer and use it in GitHub Desktop.
#!/bin/bash
# --- Command line
refname="$1"
oldrev="$2"
newrev="$3"
echo "> $refname"
echo "> $oldrev"
echo "> $newrev"
# --- Safety check
if [ -z "$GIT_DIR" ]; then
echo "Don't run this script from the command line." >&2
echo " (if you want, you could supply GIT_DIR then run" >&2
echo " $0 <ref> <oldrev> <newrev>)" >&2
exit 1
fi
if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then
echo "Usage: $0 <ref> <oldrev> <newrev>" >&2
exit 1
fi
# Create an email with the changes
SUM=$(git rev-list ${oldrev}..${newrev})
PID=$$
# Create an email from the "patch" etc, and send it out
#
GITREPOEMAIL=foo@bar
SENDMAIL=~git/bin/smtp-cli
echo "$(git show -F -C $SUM | cat)" >/tmp/msg.$PID && $SEMDMAIL: --from=git@$(hostname -f) --to=$GITREPOEMAIL --subject="GIT commit" --host=mail.server.com --missing-modules-ok --body-plain=/tmp/msg.$PID
rm -f /tmp/msg.$PID
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment