[API] Improve the logic for determining the current branch in `rake test:integration`

Git version 1.8.5.2, Mac OS X:

    $ git branch --no-color

    * (detached from 4aa5ef1)
      0.90.7
      master

Git version 1.7.9.5, Ubuntu:

    $ git branch --no-color

    * (no branch)
      0.90
      master