def git_version():
    cmd = ['git', 'describe', '--abbrev=4']
    try:
        proc = sp.Popen(cmd, stdout=sp.PIPE)
        stdout = proc.communicate()[0].rstrip('\n')
    except __HOLE__:
        sys.stderr.write('git not found: leaving __version__ alone\n')
        return __version__
    if proc.returncode != 0:
        sys.stderr.write('git describe failed: leaving __version__ alone\n')
        return __version__
    ver = stdout.lstrip('mkvtomp4-v')
    write_version(ver)
    try:
        proc = sp.Popen(['git', 'update-index', '-q', '--refresh'])
        proc.communicate()
    except OSError:
        return ver
    if proc.returncode != 0:
        return ver
    try:
        proc = sp.Popen(['git', 'diff-index', '--name-only', 'HEAD', '--'], stdout=sp.PIPE)
        stdout = proc.communicate()[0]
    except OSError:
        sys.stderr.write('git diff-index failed\n')
    if stdout.strip('\n'):
        ver = ver + '-dirty'
        write_version(ver)
    return ver
dataset/ETHPy150Open gavinbeatty/mkvtomp4/setup.py/git_version