Skip to content

Commit 8f04958

Browse files
committed
build: gate pre-commit hook install behind INSTALL_PRECOMMIT
Port the scripts/make changes from coreai-opt#497 so INSTALL_PRECOMMIT is a real knob: setup_env.sh defaults it (false in --ensure mode, true otherwise) and threads it to install_pre_commit_hooks.sh, which skips `pre-commit install -f` when INSTALL_PRECOMMIT=false.
1 parent 0ef6859 commit 8f04958

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

scripts/make/install_pre_commit_hooks.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,9 @@ if ! command -v lychee &>/dev/null; then
6060
fi
6161

6262
# Configure git hooks. Force-install so the shebang points to the current venv.
63-
uv run --no-sync --active pre-commit install -f
64-
echo "✓ Pre-commit hooks configured to use $VIRTUAL_ENV"
63+
if [[ "${INSTALL_PRECOMMIT:-true}" == "false" ]]; then
64+
echo "Skipping git hook configuration (INSTALL_PRECOMMIT=$INSTALL_PRECOMMIT)"
65+
else
66+
uv run --no-sync --active pre-commit install -f
67+
echo "✓ Pre-commit hooks configured to use $VIRTUAL_ENV"
68+
fi

scripts/make/setup_env.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,12 @@ while [[ $# -gt 0 ]]; do
195195
esac
196196
done
197197

198+
if [[ "$ENSURE_MODE" == true ]]; then
199+
INSTALL_PRECOMMIT="${INSTALL_PRECOMMIT:-false}"
200+
else
201+
INSTALL_PRECOMMIT="${INSTALL_PRECOMMIT:-true}"
202+
fi
203+
198204
# Validate required arguments
199205
if [[ -z "$PYTHON_VERSION" ]]; then
200206
echo "Error: --python-version is required"
@@ -339,11 +345,11 @@ echo "Running: ${SYNC_CMD[*]}"
339345
"${SYNC_CMD[@]}"
340346

341347
echo ""
342-
echo "[3/3] Configuring pre-commit hooks..."
348+
echo "[3/3] Installing hook dependencies and configuring pre-commit hooks..."
343349
if [[ "$VENV_PREEXISTED" == "true" ]]; then
344350
echo "Skipped (venv already exists, hooks already configured)"
345351
else
346-
"$SCRIPTS_DIR/make/install_pre_commit_hooks.sh" "$COREAI_OPT_HOME"
352+
INSTALL_PRECOMMIT="$INSTALL_PRECOMMIT" "$SCRIPTS_DIR/make/install_pre_commit_hooks.sh" "$COREAI_OPT_HOME"
347353
fi
348354

349355
echo ""

0 commit comments

Comments
 (0)