Find closest tag for a git repository.

    Note:
        This defaults to `Semantic Version`_ tag matching.

    Args:
        __matcher: Glob-style tag pattern to match
        strict: Allow commit-ish, if no tag found
        git_dir: Repository to search
    Returns:
        Matching tag name

    .. _Semantic Version: http://semver.org/

def find_tag(__matcher: str = 'v[0-9]*', *, strict: bool = True,
             git_dir: str = '.') -> str:
    """Find closest tag for a git repository.

    Note:
        This defaults to `Semantic Version`_ tag matching.

    Args:
        __matcher: Glob-style tag pattern to match
        strict: Allow commit-ish, if no tag found
        git_dir: Repository to search
    Returns:
        Matching tag name

    .. _Semantic Version: http://semver.org/
    """
    command = 'git describe --abbrev=12 --dirty'.split()
    with chdir(git_dir):
        try:
            stdout = check_output(command + ['--match={}'.format(__matcher), ])
        except CalledProcessError:
            if strict:
                raise
            stdout = check_output(command + ['--always', ])

        stdout = stdout.decode('ascii', 'replace')
    return stdout.strip()