Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
fix(release-control): scrub inherited git env in hook scratch-repo helpers
rcourtmanef50c10a9aa2
diff --git a/scripts/release_control/format_staged_go.py b/scripts/release_control/format_staged_go.pyindex 1cc560940e..8ca79a9d8d 100644--- a/scripts/release_control/format_staged_go.py+++ b/scripts/release_control/format_staged_go.py@@ -15,11 +15,13 @@ DEFAULT_REPO_ROOT = REPO_ROOTdef git_env() -> dict[str, str]:env = os.environ.copy()- # Unit tests patch REPO_ROOT to a temporary repository. In that case, an- # inherited alternate index from the caller should not leak into the temp- # repo and point git plumbing at entries from a different repository.+ # Unit tests patch REPO_ROOT to a temporary repository. In that case, the+ # inherited hook environment (alternate index, or the absolute GIT_DIR a+ # pre-commit run from a linked worktree exports) should not leak into the+ # temp repo and point git plumbing at a different repository.if REPO_ROOT != DEFAULT_REPO_ROOT:- env.pop("GIT_INDEX_FILE", None)+ for name in ("GIT_DIR", "GIT_WORK_TREE", "GIT_INDEX_FILE", "GIT_COMMON_DIR"):+ env.pop(name, None)return envdiff --git a/scripts/release_control/format_staged_go_test.py b/scripts/release_control/format_staged_go_test.pyindex 626fcd5a5c..0e9273e411 100644--- a/scripts/release_control/format_staged_go_test.py+++ b/scripts/release_control/format_staged_go_test.py@@ -11,7 +11,11 @@ from format_staged_go import format_staged_go_filesclass FormatStagedGoTest(unittest.TestCase):def git(self, repo_root: Path, *args: str) -> subprocess.CompletedProcess:env = os.environ.copy()- env.pop("GIT_INDEX_FILE", None)+ # Scrub the full hook environment: with only GIT_INDEX_FILE removed, a+ # pre-commit run from a linked worktree exports an absolute GIT_DIR and+ # "git init" here re-initializes the REAL repository as bare.+ for name in ("GIT_DIR", "GIT_WORK_TREE", "GIT_INDEX_FILE", "GIT_COMMON_DIR"):+ env.pop(name, None)return subprocess.run(["git", *args],cwd=repo_root,diff --git a/scripts/release_control/governance_stage_guard.py b/scripts/release_control/governance_stage_guard.pyindex e3a5b05b27..1beb5ccbb3 100644--- a/scripts/release_control/governance_stage_guard.py+++ b/scripts/release_control/governance_stage_guard.py@@ -31,7 +31,12 @@ DEFAULT_REPO_ROOT = REPO_ROOTdef git_env() -> dict[str, str]:env = os.environ.copy()if REPO_ROOT != DEFAULT_REPO_ROOT:- env.pop("GIT_INDEX_FILE", None)+ # Unit tests patch REPO_ROOT to a temporary repository. Scrub the full+ # inherited hook environment: a pre-commit run from a linked worktree+ # exports an absolute GIT_DIR, which would silently point git at the+ # real repository instead of the temp one.+ for name in ("GIT_DIR", "GIT_WORK_TREE", "GIT_INDEX_FILE", "GIT_COMMON_DIR"):+ env.pop(name, None)return envdiff --git a/scripts/release_control/governance_stage_guard_test.py b/scripts/release_control/governance_stage_guard_test.pyindex 90ca036215..db95d30ab1 100644--- a/scripts/release_control/governance_stage_guard_test.py+++ b/scripts/release_control/governance_stage_guard_test.py@@ -15,7 +15,11 @@ from governance_stage_guard import (class GovernanceStageGuardTest(unittest.TestCase):def git(self, repo_root: Path, *args: str) -> subprocess.CompletedProcess:env = os.environ.copy()- env.pop("GIT_INDEX_FILE", None)+ # Scrub the full hook environment: with only GIT_INDEX_FILE removed, a+ # pre-commit run from a linked worktree exports an absolute GIT_DIR and+ # "git init" here re-initializes the REAL repository as bare.+ for name in ("GIT_DIR", "GIT_WORK_TREE", "GIT_INDEX_FILE", "GIT_COMMON_DIR"):+ env.pop(name, None)return subprocess.run(["git", *args],cwd=repo_root,diff --git a/scripts/release_control/readiness_assertion_guard_test.py b/scripts/release_control/readiness_assertion_guard_test.pyindex d7c1ee1af0..2c16b5bf8b 100644--- a/scripts/release_control/readiness_assertion_guard_test.py+++ b/scripts/release_control/readiness_assertion_guard_test.py@@ -36,7 +36,11 @@ def base_payload() -> dict:class ReadinessAssertionGuardTest(unittest.TestCase):def git(self, repo_root: Path, *args: str) -> subprocess.CompletedProcess:env = os.environ.copy()- env.pop("GIT_INDEX_FILE", None)+ # Scrub the full hook environment: with only GIT_INDEX_FILE removed, a+ # pre-commit run from a linked worktree exports an absolute GIT_DIR and+ # "git init" here re-initializes the REAL repository as bare.+ for name in ("GIT_DIR", "GIT_WORK_TREE", "GIT_INDEX_FILE", "GIT_COMMON_DIR"):+ env.pop(name, None)return subprocess.run(["git", *args],cwd=repo_root,diff --git a/scripts/release_control/subsystem_contracts.py b/scripts/release_control/subsystem_contracts.pyindex a3149dfe32..e68698f5fa 100644--- a/scripts/release_control/subsystem_contracts.py+++ b/scripts/release_control/subsystem_contracts.py@@ -52,7 +52,12 @@ PATH_SUFFIXES = (def git_env() -> dict[str, str]:env = os.environ.copy()if REPO_ROOT != DEFAULT_REPO_ROOT:- env.pop("GIT_INDEX_FILE", None)+ # Unit tests patch REPO_ROOT to a temporary repository. Scrub the full+ # inherited hook environment: a pre-commit run from a linked worktree+ # exports an absolute GIT_DIR, which would silently point git at the+ # real repository instead of the temp one.+ for name in ("GIT_DIR", "GIT_WORK_TREE", "GIT_INDEX_FILE", "GIT_COMMON_DIR"):+ env.pop(name, None)return envdiff --git a/scripts/release_control/subsystem_contracts_test.py b/scripts/release_control/subsystem_contracts_test.pyindex 9c4781e7e3..cea26fef14 100644--- a/scripts/release_control/subsystem_contracts_test.py+++ b/scripts/release_control/subsystem_contracts_test.py@@ -18,7 +18,11 @@ from subsystem_contracts import (class SubsystemContractsTest(unittest.TestCase):def git(self, repo_root: Path, *args: str) -> subprocess.CompletedProcess:env = os.environ.copy()- env.pop("GIT_INDEX_FILE", None)+ # Scrub the full hook environment: with only GIT_INDEX_FILE removed, a+ # pre-commit run from a linked worktree exports an absolute GIT_DIR and+ # "git init" here re-initializes the REAL repository as bare.+ for name in ("GIT_DIR", "GIT_WORK_TREE", "GIT_INDEX_FILE", "GIT_COMMON_DIR"):+ env.pop(name, None)return subprocess.run(["git", *args],cwd=repo_root,