Rewrite switch_version() to detect branch
Rewrite switch_version() to detect branch

Rewrote switch_version() to read .git/HEAD to find branch associated
with HEAD.  If in a detached HEAD state, will read
.git/refs/remotes/<remote>/HEAD.

thaim/ansible,thaim/ansible