Greetings I have just written my first git hook script.
It It is very simple that simply finds any urlsURLs in the commit message and uses the google urlGoogle URL shortener to rewrite the urlURL nicely.
it is located here Github Commit-msghere.
I feel it could be improved immensely (as it is my first) and would love to have your input.
#! /bin/bash
message=`cat $1`
shorten=`sed -ne 's/.*\(http[^"]*\).*/\1/p' $1`
echo "Shortening Url $shorten ...."
new_url=`curl -s https://www.googleapis.com/urlshortener/v1/url \-H 'Content-Type: application/json' \-d "{'longUrl': '$shorten'}"`
latest=`echo $new_url | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["id"]';`
final=${message/$shorten/$latest}
echo $final > $1
Thanks