Skip to content

Instantly share code, notes, and snippets.

@intari
Created May 25, 2015 05:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save intari/8f260bc260acd3b24eae to your computer and use it in GitHub Desktop.
Save intari/8f260bc260acd3b24eae to your computer and use it in GitHub Desktop.
Commit hook to log commit messages as highlights to RescueTime
#!/bin/sh
#
# Log commit messages as a 'highlight' in RescueTime Premium for Mercurial
#
# To enable this hook:
#
# 1. Get your API key from https://www.rescuetime.com/integrations/git
# 2. Place this file somewhere
# 3. Make sure it has executable permissions (chmod +x post-commit)
# 4. add line commit=path/to/this to [hooks] session of your .hgrc
# 5. all commits will be automatically logged as highlight events.
#
#
API_KEY=<your_rescue_time_api_key>
# REQUIRED FIELDS - Today's date and commit message
MESSAGE=$(hg log -r $HG_NODE --template '{desc|firstline}')
DATE_TODAY=$(date +"%Y-%m-%d")
# OPTIONAL - Label
LABEL='code commit'
#if [[ ${#MESSAGE} -gt 10 ]]; then
curl --data "key=$API_KEY&highlight_date=$DATE_TODAY&description=$MESSAGE&source=$LABEL" 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