diff --git a/state-hub/scripts/consistency_check.py b/state-hub/scripts/consistency_check.py index 0b2b726..64daabb 100644 --- a/state-hub/scripts/consistency_check.py +++ b/state-hub/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: