Date Tags bti / git

I’ve recently added a hook in my git repository to send all my commits to identi.ca. There are a plethora of methods to do so, and I’ve chosen bti, that is a small program, available in debian with oauth support.

Following the instructions I found here :

  • register an application at https://identi.ca/settings/oauthapps/new
  • add consumer_key and consumer_secret into ~/.bti_oauth
  • run bti:
$ bti --config ~/.bti_oauth
Please open the following link in your browser, and allow 'bti' to access your account. Then paste back the provided PIN in here.
http://identi.ca/api/oauth/authorize?oauth_token=$token
PIN: $pin_copied_from_above_URL
Please put these two lines in your bti configuration file (~/.bti):
access_token_key=$key
access_token_secret=$secret
  • add access_token_key and access_token_secret to ~/.bti_oauth
  • try to post something:
$ bti --config ~/.bti_oauth
tweet: testing bti with oauth on identi.ca ...

Once you have bti working, you can add the following script in your post-receive script in the directory hooks.

#!/bin/bash

read oldrev newrev refname
short_refname=${refname##refs/heads/}

/usr/bin/git rev-list $oldrev...$newrev --no-merges --pretty=format:"\!dose ($short_refname): %s (%an) https://gforge.inria.fr/plugins/scmgit/cgi-bin/gitweb.cgi?p=dose/dose.git;a=commit;h=%h" --abbrev-commit | grep -v ^commit | while read a; do echo "$a" | cut -f-140 | bti --shrink-urls --logfile bti.log --config~/.bti_identica ; sleep 1; done

exit 0

your next commit should appear on identi.ca . The format string :

"\!dose ($short_refname): %s (%an) https://gforge.inria.fr/plugins/scmgit/cgi-bin/gitweb.cgi?p=dose/dose.git;a=commit;h=%h"

should print appear like this on identi.ca. Have a look at the man page of git rev-list if you want to add other info. Notice that the url gets shorten automatically and we use the !bang syntax to post in the group dose.

!dose (master): More work on the website (fix css issue) (Pietro Abate) http://identi.ca/url/73941892

For twitter is basically the same thing.