Git Push and Play Push It
This ended up being much easier than I expected. I figured the simplest thing would be to have Spotify play the song. So, I thought, how could I get Spotify to play the song on git push?
After a quick search for "git hooks" I found out that it is possible to execute a script when you do various actions in git. I found one that essentially executes when you push, cool. Half way there, in theory.
Now I needed to figure out how to get Spotify to play nice. A quick search for "Spotify Command Line" turned up this repo: https://github.com/hnarayanan/shpotify. Ok, so let's see if this thing works.
I downloaded the Spotify tool, moved it to my usr/local/bin, but I think you can move it anywhere that would put it in the PATH. Then I tested it. It works. Cool, like basically 80% of the way there now.
Back to git hooks. I looked in a repo I had locally, and found the .git folder and within it, the hooks folder. Git provides a bunch of .sample files for the various hooks available. I wanted this to happen on push, so I saw the pre-push hook. Did a search and found that it is triggered once a push is made, but before any data is sent. Pretty much perfect for what I want.
I duplicated the pre-push.sample, renamed it to
pre-push, opened it in Sublime, cleared out everything since I wasn't really using it. Added the line
spotify play push it. Saved it.
Now to test. I opened the project in Sublime, opened a file, saved it,
git add .,
git commit -m 'testing',
git push and boom, "Push It."
Not the most useful thing, but kind of fun. This only works on repos that you set it up on, haven't looked into if this is could be global for git on your computer or not. But also think it's sort of a fun idea maybe to have a song per project/repo that in an office environment could signal progress on a project.
I am also aware that this could become annoying at some point. But it really was fun, I got a little experience with git hooks, and really, just why not?
Oh, and the shpotify CLI tool seems to be Mac only. So hopefully there is something similar for Windows.