Showing posts with label coding. Show all posts
Showing posts with label coding. Show all posts

Tuesday, July 28, 2015

X-Commit-Powered-By "Header"

Just wrote this commit-msg hook for git that just has me looking forward to each commit to the project.  It's only for OSX and its sole purpose is to add a tag that looks like a custom HTTP header which shows what song was playing when the user created the commit.  It only works with iTunes and can handle when iTunes is paused.

Here's an example of how it looks:
X-Commit-Powered-By: Cake - Short Skirt / Long Jacket
 When it detects that your iTunes is paused, it outputs this instead:
X-Commit-Powered-By: Silent Meditation
 You can change all this, of course, with a little bash-fu.

Without further ado, here's the script.  Move it to your git repository's .git/hooks directory and rename it to "commit-msg".  Throw in a chmod +x .git/hook/commit-msg and you're good to go!  If you already have a commit-msg hook, you can add this snippet to the end of it (minus the hash-bang line)

#!/bin/sh
# Adds the currently playing iTunes track to the commit message

# Add a blank line
echo >> $1

state=`osascript -e 'tell application "iTunes" to player state as string'`;
if [ $state = "playing" ]; then
    artist=`osascript -e 'tell application "iTunes" to artist of current track as string'`;
    track=`osascript -e 'tell application "iTunes" to name of current track as string'`;
    echo "X-Commit-Powered-By: $artist - $track" >> $1;
else
    echo "X-Commit-Powered-By: Silent Meditation" >> $1;
fi

 Happy committing!

Tuesday, June 2, 2009

Trac 0.12 brings support for multiple repositories

If you haven't tried trac for a quick but fairly extensive project management / ticketing system / wiki for your project then you really should. Chances are, however, if you've ever used it, you've been irked by the fact that you have to create a new trac instance for every project that you want to er... trac(k) :) It looks like version 0.12 (due out in July 2009) has planned support for multiple repositories in a single instance. This will allow me to e.g. have a separate framework repository and my application repository within the same instance and track changes made to both. I wonder how they'll handle access control to the two repositories.