def get_base_branch(cherry_pick_branch):
    """
    return '2.7' from 'backport-sha-2.7'

    raises ValueError if the specified branch name is not of a form that
        cherry_picker would have created
    """
    prefix, sha, base_branch = cherry_pick_branch.split("-", 2)

    if prefix != "backport":
        raise ValueError(
            'branch name is not prefixed with "backport-".  Is this a cherry_picker branch?'
        )

    if not re.match("[0-9a-f]{7,40}", sha):
        raise ValueError(f"branch name has an invalid sha: {sha}")

    # Validate that the sha refers to a valid commit within the repo
    # Throws a ValueError if the sha is not present in the repo
    validate_sha(sha)

    # Subject the parsed base_branch to the same tests as when we generated it
    # This throws a ValueError if the base_branch doesn't meet our requirements
    version_from_branch(base_branch)

    return base_branch
def get_base_branch ( cherry_pick_branch ) : prefix , sha , base_branch = cherry_pick_branch . split ( "-" , 2 ) if prefix != "backport" : raise ValueError ( 'branch name is not prefixed with "backport-".  Is this a cherry_picker branch?' ) if not re . match ( "[0-9a-f]{7,40}" , sha ) : raise ValueError ( f"branch name has an invalid sha: {sha}" ) validate_sha ( sha ) version_from_branch ( base_branch ) return base_branch
return '2.7' from 'backport-sha-2.7'

    raises ValueError if the specified branch name is not of a form that
        cherry_picker would have created