mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-11 00:07:03 +01:00
Some checks are pending
dependency freshness / dependencies on newest stable (push) Waiting to run
md-naming / markdown naming convention (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (mypy, mypy) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (pylint, pylint) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (rest, ) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (shellcheck, shellcheck) (push) Waiting to run
Python tests / test (push) Waiting to run
repo-contract / repo contract (push) Waiting to run
Shell tests / shell-tests (push) Waiting to run
Shell tests / lib-tests (push) Waiting to run
Shell tests / arch-tests (push) Waiting to run
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JThjboXTeZ3yJPBzxMx5wS
30 lines
797 B
Python
30 lines
797 B
Python
"""One way to run git for the dashboard: absolute binary, bounded, never raises."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import shutil
|
|
import subprocess
|
|
from typing import TYPE_CHECKING
|
|
|
|
if TYPE_CHECKING:
|
|
from pathlib import Path
|
|
|
|
GIT = shutil.which("git") or "/usr/bin/git"
|
|
TIMEOUT_S = 30
|
|
|
|
|
|
def run(repo: str | Path, *args: str, stdin: str | None = None) -> str | None:
|
|
"""``git -C repo args``: stdout, or ``None`` on any failure."""
|
|
try:
|
|
done = subprocess.run(
|
|
[GIT, "-C", str(repo), *args],
|
|
input=stdin,
|
|
capture_output=True,
|
|
text=True,
|
|
check=False,
|
|
timeout=TIMEOUT_S,
|
|
)
|
|
except OSError, subprocess.TimeoutExpired:
|
|
return None
|
|
return done.stdout if done.returncode == 0 else None
|