diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100755 index 0000000..f37072b --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,30 @@ +#!/usr/bin/env bash +# Pre-commit hook: lint check on staged Python files using ruff. +# +# Install once per clone: +# git config core.hooksPath .githooks + +set -euo pipefail + +STAGED=$(git diff --cached --name-only --diff-filter=ACM | grep '\.py$' || true) + +if [ -z "$STAGED" ]; then + exit 0 +fi + +echo "Running ruff lint check..." + +if command -v uv &>/dev/null; then + RUFF="uv run ruff" +else + RUFF="ruff" +fi + +if ! $RUFF check $STAGED; then + echo "" + echo "Lint check failed. Fix the issues above, re-stage the files, and commit again." + echo "To auto-fix: $RUFF check --fix $STAGED" + exit 1 +fi + +echo "Lint check passed." diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b03d47f..cedc79c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -5,11 +5,21 @@ Thanks for your interest in contributing! ## Getting Started ```bash -git clone https://github.com/iamvirul/vecgrep -cd vecgrep -uv sync +git clone https://github.com/VecGrep/VecGrep +cd VecGrep +uv sync --extra dev ``` +### Install the git hooks + +Run once after cloning to enable the pre-commit lint check: + +```bash +git config core.hooksPath .githooks +``` + +This runs `ruff` against staged Python files before every commit and blocks the commit if any violations are found. + ## Development Run the server locally: