def mzbuild_tag(git_ref: str) -> str:
    if (not git_ref):
        return git_ref
    try:
        return subprocess.check_output(['git', 'describe', '--exact-match', git_ref], stderr=subprocess.STDOUT).strip().decode()
    except subprocess.CalledProcessError:
        unstable_ref = subprocess.check_output(['git', 'rev-parse', '--verify', git_ref]).strip().decode()
        return f'unstable-{unstable_ref}'
def mzbuild_tag(git_ref: str) -> str:
    if (not git_ref):
        return git_ref
    try:
        return subprocess.check_output(['git', 'describe', '--exact-match', git_ref], stderr=subprocess.STDOUT).strip().decode()
    except subprocess.CalledProcessError:
        unstable_ref = subprocess.check_output(['git', 'rev-parse', '--verify', git_ref]).strip().decode()
        return f'unstable-{unstable_ref}'