Add pre-commit git hook to run lintrunner on staged files#28013
Merged
vraspar merged 3 commits intomicrosoft:mainfrom Apr 9, 2026
Merged
Add pre-commit git hook to run lintrunner on staged files#28013vraspar merged 3 commits intomicrosoft:mainfrom
vraspar merged 3 commits intomicrosoft:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds an opt-in Git pre-commit hook that runs lintrunner against the files being committed, aiming to catch lint/format issues earlier and reduce CI churn.
Changes:
- Document how to enable/bypass the repo-provided Git hooks via
core.hooksPath. - Add a
.githooks/pre-commitscript that runs lintrunner in check-only mode and blocks commits on failure. - Ensure
.githooksuses LF line endings via.gitattributes.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| CONTRIBUTING.md | Documents enabling the pre-commit hook and basic usage/bypass guidance. |
| .githooks/pre-commit | Implements a pre-commit hook that runs lintrunner on paths from the index. |
| .gitattributes | Forces LF endings for hooks to work consistently across platforms. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
edgchen1
reviewed
Apr 9, 2026
Contributor
edgchen1
left a comment
There was a problem hiding this comment.
thanks for adding this!
edgchen1
previously approved these changes
Apr 9, 2026
edgchen1
approved these changes
Apr 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Add a pre-commit git hook that runs lintrunner on staged files, catching lint and formatting issues before they reach CI.
The hook runs lintrunner in check-only mode (no auto-fix) to avoid issues with partial staging. If lint issues are found, the commit is blocked and the developer is prompted to run
lintrunner -ato fix.The hook is opt-in. Contributors enable it with:
git config core.hooksPath .githooksMotivation and Context
Follow-up from #27856. Catching lint issues at commit time saves CI cycles and review time.