code: def get_travis_branch():
        # noqa E501
      try:
          travis_pull_request = get_travis_env_or_fail('TRAVIS_PULL_REQUEST')
          if truthy(travis_pull_request):
              travis_pull_request_branch = get_travis_env_or_fail(
                  'TRAVIS_PULL_REQUEST_BRANCH')
              return travis_pull_request_branch
          else:
              travis_branch = get_travis_env_or_fail('TRAVIS_BRANCH')
              return travis_branch
      except UnexpectedTravisEnvironmentError:
          return None
docs: Get current branch per Travis environment variables
  
      If travis is building a PR, then TRAVIS_PULL_REQUEST is truthy and the
      name of the branch corresponding to the PR is stored in the
      TRAVIS_PULL_REQUEST_BRANCH environment variable. Else, the name of the
      branch is stored in the TRAVIS_BRANCH environment variable.
  
      See also: <https://docs.travis-ci.com/user/environment-variables/#default-environment-variables>