Skip to content

Instantly share code, notes, and snippets.

@felippenardi
Last active October 20, 2015 01:37
Show Gist options
  • Save felippenardi/ae979017aa3280249c02 to your computer and use it in GitHub Desktop.
Save felippenardi/ae979017aa3280249c02 to your computer and use it in GitHub Desktop.
Sending your commits to Rescue Time
#!/bin/sh
#
# An example hook script to log commit messages
# as a 'daily highlight' in RescueTime Premium
#
# See README.md for more information
#
# To enable this hook:
#
# 1. Place this file in .git/hooks and rename to "post-commit".
#
# 2. Update the value of API_KEY below with a valid RescueTime API key.
# [ you can generate a key at https://www.rescuetime.com/anapi/manage ]
API_KEY=INSERT_YOUR_API_KEY_HERE
# REQUIRED FIELDS - Today's date and commit message
MESSAGE=$(git log -1 HEAD --pretty=format:%s)
DATE_TODAY=$(date +"%Y-%m-%d")
# You can edit the LABEL value if you would rather
# describe these commits differently.
DIRECTORY=$(basename "$PWD")
# It will send all commit messages with more than 15 characters
if [ ${#MESSAGE} -gt 15 ]; then
curl --data "key=$API_KEY&highlight_date=$DATE_TODAY&description=$MESSAGE&source=$DIRECTORY%20commits" https://www.rescuetime.com/anapi/highlights_post
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment