The main gitshed functionality.

Pulls together code from previous commits.

The main() wrapper, BUILD files etc. will follow shortly.
I found this code very difficult to read going into it not knowing what it was going to be doing. I was jumping around between the string, the format call, and the other variables. What about using named format variables rather than indexes?