#!/bin/bash # NOTE: actually it would be nice to add something like the branch and SHA, but for the sake of demonstration I'm just using this file to feed Wakatime # these variables are not used, but they might be useful; for someone else to play around MESSAGE=$1 SHA=$(git rev-parse HEAD) BRANCH=$(git symbolic-ref --short HEAD) # give it a name PLUGIN="githook-wakatime/0.0.1" # read the API key API_KEY=$(awk '/^api_key/{print $NF}' ~/.wakatime.cfg) # make sure we stay in this directory DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # feed Wakatime with a file; anyone withh a better idea? FILE="$DIR/post-commit" # download Wakatime CLI if necessary if [ ! -d "$DIR/wakatime" ]; then mkdir "$DIR/wakatime" wget -t 30 -w 5 --waitretry 20 --random-wait -O - https://github.com/wakatime/wakatime/archive/master.tar.gz | tar -C "$DIR/wakatime" --strip-components=1 -zxv fi # NOTE: in case you want to test more then enable this line #python wakatime/wakatime-cli.py --write --verbose --logfile wakatime.log --file "$FILE" --key "$API_KEY" --plugin "$PLUGIN" python "$DIR/wakatime/wakatime-cli.py" --write --file "$FILE" --key "$API_KEY" --plugin "$PLUGIN" # optionally you could provide the --project parameter here to aggregate the stats in a separate project; # maybe there will be a better solution once Alan has implemented the categories feature