Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a script that posts git commits to twitter?

Tags:

git

twitter

Git is notorious by its encouraged length limit for commit message titles: first line should not be more than 50 characters long (to fit an e-mail header).

That reminds me of... well, is there a hook that automatically posts commit messages to twitter as soon as they're pushed to the server?

like image 594
P Shved Avatar asked Apr 16 '10 12:04

P Shved


2 Answers

Here you go:

#!/bin/sh
username=<your Twitter account>
password=<your Twitter password>

service_uri=http://api.twitter.com/1/statuses/update.json

subject=`git log --pretty=format:%s -n1`

curl -u "${username}:${password}" -d status="${subject}" $service_uri

Save as .git/hooks/post-commit in your repository and make it executable.

[Note: completely untested, I just made this up on the spot.]

like image 116
Jörg W Mittag Avatar answered Oct 26 '22 04:10

Jörg W Mittag


Github does this with their "Service Hooks" feature. The code for it is here: github/github-services/lib/services/twitter.rb

like image 22
Michael Borgwardt Avatar answered Oct 26 '22 05:10

Michael Borgwardt