Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env bash
# Canonical CAVA pre-commit hook: keeps uv.lock in sync with pyproject.toml.
#
# If pyproject.toml is staged, finds the specific dependency line(s) that
# changed (added, removed, or had their version spec edited) and refreshes
# only those packages in uv.lock via `uv lock --upgrade-package`. Does not
# touch any other package -- this is a targeted sync, not a blanket
# `uv lock`, so it never pulls in an unrelated upstream release.
set -euo pipefail

if ! git diff --cached --name-only | grep -q '^pyproject\.toml$'; then
exit 0
fi

if ! command -v uv >/dev/null 2>&1; then
echo "pre-commit: uv not found on PATH, skipping uv.lock sync" >&2
exit 0
fi

changed_names=$(git diff --cached -- pyproject.toml \
| grep -E '^[+-]\s*"[A-Za-z0-9][A-Za-z0-9._-]*' \
| sed -E 's/^[+-]\s*"([A-Za-z0-9][A-Za-z0-9._-]*).*/\1/' \
| sort -u)

if [ -z "$changed_names" ]; then
exit 0
fi

upgrade_args=()
while IFS= read -r name; do
upgrade_args+=(--upgrade-package "$name")
done <<< "$changed_names"

echo "pre-commit: syncing uv.lock for changed dependencies:"
echo "$changed_names" | sed 's/^/ - /'
uv lock "${upgrade_args[@]}"
git add uv.lock
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ authors = [
requires-python = ">=3.12"
dependencies = [
"chardet>=5.2.0",
"oa-configurator==0.1.2",
"oa-configurator>=0.1.2,<1.0.0",
"pandas>=2.3.3",
"pyarrow>=23.0.1",
"sqlalchemy>=2.0.45",
Expand Down Expand Up @@ -49,7 +49,7 @@ postgres = [
"psycopg[binary]>=3.2",
]
dev = [
"oa-configurator[postgres]==0.1.2",
"oa-configurator[postgres]>=0.1.2,<1.0.0",
"pytest>=9.0.3",
"ty>=0.0.59",
"ruff>=0.14.11",
Expand Down
4 changes: 2 additions & 2 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading