Handle case when using detached branch (as Travis CI does)

If the current branch is detached, handle it gracefully. An attempt to checkout the branch '(no branch)' will fail. In this case, the current commit sha (retrieved from revparse HEAD) must be used as the return branch.

This problem is observed when Travis CI uses this deployer.