PHP 8.2.30
Preview: _git.py Size: 784 B
/opt/hc_python/lib/python3.12/site-packages/pydantic/_internal/_git.py

"""Git utilities, adopted from mypy's git utilities (https://github.com/python/mypy/blob/master/mypy/git.py)."""

from __future__ import annotations

import os
import subprocess


def is_git_repo(dir: str) -> bool:
    """Is the given directory version-controlled with git?"""
    return os.path.exists(os.path.join(dir, '.git'))


def have_git() -> bool:
    """Can we run the git executable?"""
    try:
        subprocess.check_output(['git', '--help'])
        return True
    except subprocess.CalledProcessError:
        return False
    except OSError:
        return False


def git_revision(dir: str) -> str:
    """Get the SHA-1 of the HEAD of a git repository."""
    return subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD'], cwd=dir).decode('utf-8').strip()

Directory Contents

Dirs: 1 × Files: 26

Name Size Perms Modified Actions
- drwxr-xr-x 2025-04-04 08:02:07
Edit Download
12.31 KB lrw-r--r-- 2025-04-04 08:02:07
Edit Download
3.44 KB lrw-r--r-- 2025-04-04 08:02:07
Edit Download
23.70 KB lrw-r--r-- 2025-04-04 08:02:07
Edit Download
8.53 KB lrw-r--r-- 2025-04-04 08:02:07
Edit Download
31.21 KB lrw-r--r-- 2025-04-04 08:02:07
Edit Download
6.06 KB lrw-r--r-- 2025-04-04 08:02:07
Edit Download
25.82 KB lrw-r--r-- 2025-04-04 08:02:07
Edit Download
3.70 KB lrw-r--r-- 2025-04-04 08:02:07
Edit Download
14.58 KB lrw-r--r-- 2025-04-04 08:02:07
Edit Download
611 B lrw-r--r-- 2025-04-04 08:02:07
Edit Download
102.91 KB lrw-r--r-- 2025-04-04 08:02:07
Edit Download
21.69 KB lrw-r--r-- 2025-04-04 08:02:07
Edit Download
784 B lrw-r--r-- 2025-04-04 08:02:07
Edit Download
144 B lrw-r--r-- 2025-04-04 08:02:07
Edit Download
13.86 KB lrw-r--r-- 2025-04-04 08:02:07
Edit Download
7.14 KB lrw-r--r-- 2025-04-04 08:02:07
Edit Download
30.63 KB lrw-r--r-- 2025-04-04 08:02:07
Edit Download
4.46 KB lrw-r--r-- 2025-04-04 08:02:07
Edit Download
4.74 KB lrw-r--r-- 2025-04-04 08:02:07
Edit Download
6.15 KB lrw-r--r-- 2025-04-04 08:02:07
Edit Download
28.20 KB lrw-r--r-- 2025-04-04 08:02:07
Edit Download
18.97 KB lrw-r--r-- 2025-04-04 08:02:07
Edit Download
12.36 KB lrw-r--r-- 2025-04-04 08:02:07
Edit Download
3.70 KB lrw-r--r-- 2025-04-04 08:02:07
Edit Download
10.86 KB lrw-r--r-- 2025-04-04 08:02:07
Edit Download
0 B lrw-r--r-- 2025-04-04 08:02:07
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).