From 86c75c138bd3451adaab34a898dcc4e9164bc709 Mon Sep 17 00:00:00 2001 From: iamvirul Date: Fri, 27 Feb 2026 11:37:33 +0530 Subject: [PATCH] chore: add .githooks pre-commit lint check Adds a pre-commit hook that runs ruff against staged Python files. Contributors activate it once with: git config core.hooksPath .githooks Updates CONTRIBUTING.md with setup instructions and corrects the clone URL to the new VecGrep org. Closes #32 --- .githooks/pre-commit | 30 ++++++++++++++++++++++++++++++ CONTRIBUTING.md | 16 +++++++++++++--- 2 files changed, 43 insertions(+), 3 deletions(-) create mode 100755 .githooks/pre-commit 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: