Pre-Commit Integration¶
Updates pre-commit hook versions in .pre-commit-config.yaml files.
Overview¶
Integration ID: precommit
Manifest Files: .pre-commit-config.yaml
Update Strategy: Native command - Uses pre-commit autoupdate
Registry: GitHub Releases (per hook repository)
Status: ✅ Stable
What Gets Updated¶
Hook repository revisions in the repos list:
repos[].rev- Git tag or commit SHA of each hook repository- Remote hooks only (local and meta hooks skipped)
Example¶
Before:
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: trailing-whitespace
- id: check-yaml
- repo: https://github.com/psf/black
rev: 22.10.0
hooks:
- id: black
- repo: local # Not updated
hooks:
- id: custom-check
After:
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0 # Updated
hooks:
- id: trailing-whitespace
- id: check-yaml
- repo: https://github.com/psf/black
rev: 24.10.0 # Updated
hooks:
- id: black
- repo: local # Unchanged
hooks:
- id: custom-check
Integration-Specific Behavior¶
Why Native Command?¶
uptool uses pre-commit autoupdate instead of custom rewriting because:
- Manifest-first: Updates
.pre-commit-config.yamldirectly ✅ - Comprehensive: Handles all edge cases (local hooks, complex revisions)
- Maintained: pre-commit team owns the update logic
- Reliable: Battle-tested by entire pre-commit ecosystem
This aligns with uptool's philosophy: use native commands when they update manifests.
Hook Types¶
| Type | Example | Updated? |
|---|---|---|
| Remote | repo: https://github.com/... |
✅ Yes |
| Local | repo: local |
❌ No |
| Meta | repo: meta |
❌ No |
GitHub Rate Limits¶
pre-commit autoupdate queries GitHub API for each hook. Set GITHUB_TOKEN for higher limits:
- Unauthenticated: 60 requests/hour
- Authenticated: 5,000 requests/hour
Configuration¶
version: 1
integrations:
- id: precommit
enabled: true
policy:
update: major # Aggressive for dev tools (safe)
allow_prerelease: false
Requirements¶
- pre-commit installed: Must be in
$PATH - Git repository: pre-commit requires git
- Valid config:
.pre-commit-config.yamlmust be valid YAML
Install pre-commit:
pip install pre-commit
# or
brew install pre-commit
# or
mise install pre-commit
# Verify
pre-commit --version
Limitations¶
- Requires pre-commit CLI: Must have
pre-commitinstalled and in PATH. - Git repository required: pre-commit needs a git repository to operate.
- Limited policy control: pre-commit decides what to update (up tool passes preferences where supported).
See Also¶
- CLI Reference -
uptool scan --only precommit - Configuration Guide - Policy settings
- pre-commit Documentation
- Supported Hooks