Skip to content

Instantly share code, notes, and snippets.

@ralmn
Created January 19, 2015 20:15
Show Gist options
  • Save ralmn/6eac1b12538bd9b2245b to your computer and use it in GitHub Desktop.
Save ralmn/6eac1b12538bd9b2245b to your computer and use it in GitHub Desktop.
Git hook commit tweet
#!/usr/bin/python
from TwitterAPI import TwitterAPI
import sys
TWTTR_CUSUMER_KEY = ''
TWTTR_CUSUMER_SECRET = ''
TWTTR_USER_KEY = ''
TWTTR_USER_SECRET = ''
if sys.argv:
args = sys.argv[1:]
repoName = args[0]
if repoName in ['nonDuRepo']:
branch = args[1]
author = args[2]
twitter = TwitterAPI(TWTTR_CUSUMER_KEY, TWTTR_CUSUMER_SECRET, TWTTR_USER_KEY, TWTTR_USER_SECRET)
commit_text = ' '.join(args[3:])
tweetText = '%s/%s %s (%s)' %(repoName, branch, '%s', author)
if len(tweetText) - 2 + len(commit_text) > 140:
size = len(commit_text) - len(tweetText) - 1
commit_text = commit_text[:size] + '...'
tweetText = tweetText % commit_text
twitter.request('statuses/update', {'status':tweetText})
#!/bin/bash
branch=$(echo $1 |cut -d'/' -f3)
for commit in $(git rev-list $2..$3 | tac); do
repoName=$(echo $(basename $PWD) |sed s/.git//)
authorName=$(git show -s --format="%aN" $commit)
message=$(git show -s --format="%s" $commit)
logger $repoName $branch $authorName $message
~/tweetCommit.py $repoName $branch $authorName $message
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment