-
-
Notifications
You must be signed in to change notification settings - Fork 638
Fix pre-commit hook to only check changed files #2013
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Previously, the ruby-autofix hook would run `bundle exec rake autofix` which checks ALL 154 files in the project, making commits (especially release commits) very slow. Now it runs `bundle exec rubocop -A` only on the changed Ruby files, dramatically reducing pre-commit time from ~24 seconds to just a few seconds for typical commits. During release, this will still check all changed version files and Gemfile.locks, but not every file in the entire codebase. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
|
Warning Rate limit exceeded@justin808 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 14 minutes and 9 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Code Review✅ Overall AssessmentThis is a well-targeted performance optimization that significantly improves developer experience. The change is minimal, focused, and aligns with the project's conventions. 🎯 Strengths
🔍 Technical ReviewCode Quality
Edge Cases Handled
|
Code Review - PR #2013OverviewThis PR optimizes the pre-commit hook performance by running RuboCop only on changed files instead of the entire project. The change reduces commit time from ~24s to <1s for typical commits. ✅ Strengths
🔍 Code QualityThe implementation is correct:
|
| Scenario | Before | After | Improvement |
|---|---|---|---|
| Typical commit (1-3 files) | ~24s | <1s | 96% faster |
| Release commit (version files) | ~24s | <1s | 96% faster |
🔒 Security Considerations
No security concerns. The change reduces the scope of operations, making it safer if anything.
✅ Final Recommendation
APPROVE with minor suggestion
The core change is excellent and should be merged. Consider the minor cleanup suggestions:
- Address the duplicate RuboCop runs in
.lefthook.yml(remove eitherautofixorrubocopcommand) - Optionally rename the hook to
ruby-autofixfor clarity
Great work on this optimization! This will significantly improve the developer experience. 🚀
Summary
ruby-autofixpre-commit hook to run RuboCop only on changed Ruby filesProblem
The pre-commit hook was running
bundle exec rake autofixwhich checks ALL files in the project:This made every commit (especially release commits) very slow at ~24 seconds.
Solution
Changed
bin/lefthook/ruby-autofixto runbundle exec rubocop -Adirectly on only the changed files:The
get-changed-filesscript already identifies which files changed, but we were ignoring that and running the full rake task.Test Plan
🤖 Generated with Claude Code
This change is