import re


def git2pep440(git_ver):
    """Transforms git-describe output into PEP440 compatible format.

    Examples:
        v1.0.1.rc5-24-abcdef => 1.0.1.rc5+24.abcdef
        v3.0-90-a89abc => 3.0+90.a89abc
    """
    def _git2pep440(match):
        major, minor, _3, patch, _5, rcdevversion, rcdevtype,_8, distance, _10, \
        commit = match.groups()
        version_string = f"{major}.{minor}"
        if _3:
            version_string += f".{patch}"
        if _5:
            version_string += f".{rcdevversion}"
        if _8:
            version_string += f"+{distance}.{commit}"
        return version_string
    
    return re.sub('v?([0-9]+)\.([0-9]+)(\.([0-9]+))?(\.((rc|dev)[0-9]+))?(-([0-9]+))?(-g([0-9a-fA-F]+))?', _git2pep440, git_ver)