From f896cd6f7f1d853c71f6f09802d1e4195917b8a2 Mon Sep 17 00:00:00 2001 From: Ashwin Bhat Date: Tue, 14 Oct 2025 09:26:49 -0700 Subject: [PATCH] feat: add pre-push hook for lint checks (#254) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds a committable pre-push hook that runs ruff checks before pushing, matching the CI lint workflow. Developers run ./scripts/initial-setup.sh to install the hook locally. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude --- README.md | 10 ++++++++++ scripts/initial-setup.sh | 22 ++++++++++++++++++++++ scripts/pre-push | 30 ++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100755 scripts/initial-setup.sh create mode 100755 scripts/pre-push diff --git a/README.md b/README.md index 80ff1e3..1fcb30d 100644 --- a/README.md +++ b/README.md @@ -280,6 +280,16 @@ If you're upgrading from the Claude Code SDK (versions < 0.1.0), please see the - Settings isolation and explicit control - New programmatic subagents and session forking features +## Development + +If you're contributing to this project, run the initial setup script to install git hooks: + +```bash +./scripts/initial-setup.sh +``` + +This installs a pre-push hook that runs lint checks before pushing, matching the CI workflow. To skip the hook temporarily, use `git push --no-verify`. + ## License MIT diff --git a/scripts/initial-setup.sh b/scripts/initial-setup.sh new file mode 100755 index 0000000..de6ff60 --- /dev/null +++ b/scripts/initial-setup.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +# Initial setup script for installing git hooks + +set -e + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" + +echo "Setting up git hooks..." + +# Install pre-push hook +echo "→ Installing pre-push hook..." +cp "$SCRIPT_DIR/pre-push" "$REPO_ROOT/.git/hooks/pre-push" +chmod +x "$REPO_ROOT/.git/hooks/pre-push" +echo "✓ pre-push hook installed" + +echo "" +echo "✓ Setup complete!" +echo "" +echo "The pre-push hook will now run lint checks before each push." +echo "To skip the hook temporarily, use: git push --no-verify" diff --git a/scripts/pre-push b/scripts/pre-push new file mode 100755 index 0000000..f009b61 --- /dev/null +++ b/scripts/pre-push @@ -0,0 +1,30 @@ +#!/bin/bash + +# Pre-push hook to run lint checks (matches .github/workflows/lint.yml) + +echo "Running lint checks before push..." +echo "" + +# Run ruff check +echo "→ Running ruff check..." +python -m ruff check src/ tests/ +if [ $? -ne 0 ]; then + echo "" + echo "❌ ruff check failed. Fix lint issues before pushing." + echo " Run: python -m ruff check src/ tests/ --fix" + exit 1 +fi + +# Run ruff format check +echo "→ Running ruff format check..." +python -m ruff format --check src/ tests/ +if [ $? -ne 0 ]; then + echo "" + echo "❌ ruff format check failed. Fix formatting before pushing." + echo " Run: python -m ruff format src/ tests/" + exit 1 +fi + +echo "" +echo "✓ All lint checks passed!" +exit 0