-
-
Save davidbb/2654127 to your computer and use it in GitHub Desktop.
SVN Post-commit hook for Pushover messages.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment