Fix branchName regex and a related bug.

@devoncarew  TBR