Skip to content

Commit f896cd6

Browse files
ashwin-antclaude
andauthored
feat: add pre-push hook for lint checks (#254)
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 <[email protected]>
1 parent aebcf9d commit f896cd6

File tree

3 files changed

+62
-0
lines changed

3 files changed

+62
-0
lines changed

β€ŽREADME.mdβ€Ž

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,16 @@ If you're upgrading from the Claude Code SDK (versions < 0.1.0), please see the
280280
- Settings isolation and explicit control
281281
- New programmatic subagents and session forking features
282282

283+
## Development
284+
285+
If you're contributing to this project, run the initial setup script to install git hooks:
286+
287+
```bash
288+
./scripts/initial-setup.sh
289+
```
290+
291+
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`.
292+
283293
## License
284294

285295
MIT

β€Žscripts/initial-setup.shβ€Ž

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
# Initial setup script for installing git hooks
4+
5+
set -e
6+
7+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8+
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
9+
10+
echo "Setting up git hooks..."
11+
12+
# Install pre-push hook
13+
echo "β†’ Installing pre-push hook..."
14+
cp "$SCRIPT_DIR/pre-push" "$REPO_ROOT/.git/hooks/pre-push"
15+
chmod +x "$REPO_ROOT/.git/hooks/pre-push"
16+
echo "βœ“ pre-push hook installed"
17+
18+
echo ""
19+
echo "βœ“ Setup complete!"
20+
echo ""
21+
echo "The pre-push hook will now run lint checks before each push."
22+
echo "To skip the hook temporarily, use: git push --no-verify"

β€Žscripts/pre-pushβ€Ž

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
3+
# Pre-push hook to run lint checks (matches .github/workflows/lint.yml)
4+
5+
echo "Running lint checks before push..."
6+
echo ""
7+
8+
# Run ruff check
9+
echo "β†’ Running ruff check..."
10+
python -m ruff check src/ tests/
11+
if [ $? -ne 0 ]; then
12+
echo ""
13+
echo "❌ ruff check failed. Fix lint issues before pushing."
14+
echo " Run: python -m ruff check src/ tests/ --fix"
15+
exit 1
16+
fi
17+
18+
# Run ruff format check
19+
echo "β†’ Running ruff format check..."
20+
python -m ruff format --check src/ tests/
21+
if [ $? -ne 0 ]; then
22+
echo ""
23+
echo "❌ ruff format check failed. Fix formatting before pushing."
24+
echo " Run: python -m ruff format src/ tests/"
25+
exit 1
26+
fi
27+
28+
echo ""
29+
echo "βœ“ All lint checks passed!"
30+
exit 0

0 commit comments

Comments
Β (0)