def branch_exists(branch):
    """Gets the commit hash of HEAD in the given branch.

    Args:
        branch: String; containing the name of a branch.

    Returns:
        Boolean indicating whether or not the branch exists.
    """
    # http://stackoverflow.com/questions/5167957
    ref = BRANCH_REF_TEMPLATE % branch
    status_code, _, _ = capture_command('git', 'show-ref', '--verify',
                                        '--quiet', ref, expect_success=False)
    return status_code == 0


# Rietveld Specific methods and classes
dataset/ETHPy150Open googlearchive/git-rv/utils.py/branch_exists/original