Push default branch logic down into repository, use default for Stash.

This seemed like a good idea. Also allows us to shortcut the `O(n)` branch traversal for master builds on Stash.