Partly out of curiosity, and partly because I wanted to play with the twitter API, I’ve hacked together a little script to push subversion commit details to twitter. It’s actually so simple it isn’t funny.
You will need:
- A twitter account. Username and password. Duh.
- A subversion repository. Duh.
- The ‘curl’ utility.
I’m running subversion on a Linux machine that faces the ‘net. If you’re running Windows or you’re behind a proxy or whatever YMMV. Anyway. Go into the subversion repository and find the hooks directory.
Next, create a post commit hook script. My repository didn’t have a script, so I copied the template (post-commit.tmpl) and used that. I called it post-commit, and make it executable (chmod 777 post-commit).
I then added the following two lines to the script:
COMMENT=`svnlook log -r${REV} ${REPOS}`
curl –basic –user username:password–data status=”${COMMENT}” \ http://twitter.com/statuses/update.xml
The first line uses the svnlook client to get the log message associated with the revision that was checked into the repository. ${REV} and ${REPOS} are defined for you in the post-commit.tmpl file.
The second line uses curl to post the status update to twitter using a HTTP POST. Put your twitter username and password after the –user switch. Use your username, not your email address.
That’s it. Next time you check code in you’ll publish the comment associated with the commit via your twitter account. Twitter me (http://twitter.com/AndrewLighten) if you need help, but this really is so simple it isn’t funny.
—
References:
- This blog post shows how to post to twitter using curl.
- The subversion documentation discusses subversion hooks. See the Implementing Repository Hooks section in chapter 5 (Repository Administration).
Filed under: Development, Hacks, SourceControl | 1 Comment
Hi,
Do you really need to chmod() it to 777 ? maybe you meant 755 ?
Slavi