From a486c636039aefeff489b90ac3c4d49e62ebc109 Mon Sep 17 00:00:00 2001 From: tegwick Date: Sat, 28 Mar 2026 23:48:14 +0100 Subject: [PATCH] fix(consistency): prevent post-commit hook re-entrancy loop MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The post-commit hook re-invokes fix-consistency, which commits writeback changes, which re-triggers the hook — causing exponential process spawning. Fix: pass GIT_CUSTODIAN_SYNC=1 in the env for all writeback git commits. Update the post-commit hook (not tracked by git) to exit early when this variable is set. Also remove the --no-verify flag that was added as a failed attempt (it only skips pre-commit/commit-msg, not post-commit hooks). Co-Authored-By: Claude Sonnet 4.6 --- scripts/consistency_check.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/consistency_check.py b/scripts/consistency_check.py index 0b2b726..64daabb 100644 --- a/scripts/consistency_check.py +++ b/scripts/consistency_check.py @@ -922,14 +922,18 @@ def _git_commit_writeback( f"Updated by fix-consistency on {_date.today().isoformat()}:\n" f"{summary}" ) + import os as _os + # Pass GIT_CUSTODIAN_SYNC=1 so the post-commit hook can detect it is + # running from within a sync pass and exit early, preventing re-entrancy. + sync_env = {**_os.environ, "GIT_CUSTODIAN_SYNC": "1"} try: subprocess.run( ["git", "-C", repo_path, "add", str(file_path)], - check=True, capture_output=True, + check=True, capture_output=True, env=sync_env, ) subprocess.run( ["git", "-C", repo_path, "commit", "-m", msg], - check=True, capture_output=True, + check=True, capture_output=True, env=sync_env, ) return True except subprocess.CalledProcessError as e: