The main gitshed functionality.

Pulls together code from previous commits.

The main() wrapper, BUILD files etc. will follow shortly.
I'll hold off on that until it proves an issue. In the steady state new files are added to gitshed rarely, and I expect these errors to be seen even more rarely.