Skip to content

Instantly share code, notes, and snippets.

@cpu
Created May 2, 2012 21:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cpu/2580649 to your computer and use it in GitHub Desktop.
Save cpu/2580649 to your computer and use it in GitHub Desktop.
SVN Post-commit hook for Pushover messages.
#!/bin/bash
#
# SVN Post-commit hook for the Pushover API
# Filters commits to only push when specific authors commit.
# Sends commit messages to one or more device KEYS.
# List of keys to push to
KEYS=( DEVICE_KEY_ONE DEVICE_KEY_TWO DEVICE_KEY_THREE )
# Which commit authors should generate push messages?
AUTHORS=( authora authorb authorc )
# Pushover API key
TOKEN="APPLICATION_API_KEY_HERE"
# Arguments to post-commit hook
REPOS="$1"
REV="$2"
AUTHOR=`svnlook -r $REV author $REPOS`
#this madness first removes non-printable ascii, then takes the first 450 chars
#to avoid hitting the 512 char limit of pushover
COMMIT_MESSAGE=`svnlook -r $REV log $REPOS`
MESSAGE=`echo $COMMIT_MESSAGE | tr -cd '\11\12\40-\176' | nawk '{print substr($0,1,450)}'`
FILESCHANGED=`svnlook -r $REV changed $REPOS | wc -l`
if [ "$MESSAGE" = "" ]
then
#there was no commit message
MESSAGE="No commit message"
fi
# Check that the author of the commit is in our AUTHORS array
match=$(echo ${AUTHORS[@]} | grep -o $AUTHOR)
# If the author is in AUTHORS, send a push notification to all the KEYS
if [[ ! -z $match ]]
then
for USER in "${KEYS[@]}"
do
/usr/bin/curl -s \
-F "token=$TOKEN" \
-F "user=$USER" \
-F "title=$AUTHOR commited $REV." \
-F "message=Commit message: $MESSAGE" \
https://api.pushover.net/1/messages
done
fi
@davidbb
Copy link

davidbb commented May 10, 2012

please update this repo from my fork kthx https://gist.github.com/2654127

@cpu
Copy link
Author

cpu commented May 10, 2012

Pulled changes from @davidbb to filter & trim absurd commit messages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment