rewrite branch testing code for AppVeyor use
rewrite branch testing code for AppVeyor use

* add support for testing with a detached HEAD (via heuristic current branch discovery)
* re-order the test code, placing branch info extraction closer to it's actual use
* fix $remote['url'] matching logic (regex repair and whitespace removal)

.# Discussion

AppVeyor tests the branch/commit in detached-HEAD mode, severing the direct link to the
branch under test. Importantly, for trial release branches, this lead to an important
final test being skipped on the AppVeyor platform.

When testing under detached-HEAD mode, the most likely current branch is determined
heuristically by searching for the most recently committed branch that contains the
current HEAD. This works very well for AppVeyor which only checks out the branch under
examination.

rivy/scoop