- Copy to PROJECT/.git/hooks/post-commit
- chmod u+x PROJECT/.git/hooks/post-commit
- Edit and fix your config
- Do some commits.
Last active
December 19, 2016 04:36
-
-
Save jmhobbs/4747e794a47943f8e2ab to your computer and use it in GitHub Desktop.
git post commit hook to harvest active timer
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
#!/usr/local/bin/python | |
import requests | |
import subprocess | |
# Configure Your Info Here | |
DOMAIN = "https://YOU.harvestapp.com" | |
USERNAME = "" | |
PASSWORD = "" | |
# / End Config | |
headers = { | |
'Accept': 'application/json', | |
'User-Agent': 'git post commit hook', | |
} | |
log = subprocess.check_output(["git", "log", "--pretty=oneline", "--no-decorate", "--abbrev-commit", "-1", "HEAD"]) | |
response = requests.get("%s/daily" % DOMAIN, headers=headers, auth=(USERNAME, PASSWORD)) | |
today = response.json() | |
for day_entry in today['day_entries']: | |
if "timer_started_at" in day_entry: | |
if not day_entry["notes"]: | |
day_entry["notes"] = "" | |
day_entry["notes"] = "\n".join((day_entry["notes"], log)) | |
requests.post("%s/daily/update/%s" % (DOMAIN, day_entry["id"]), data=day_entry, headers=headers, auth=(USERNAME, PASSWORD)) | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Worked like a charm! Pretty freaking cool.