[build] add smart targeting and --lint flag to format.sh#17035
[build] add smart targeting and --lint flag to format.sh#17035titusfortner merged 12 commits intotrunkfrom
Conversation
PR TypeEnhancement Description
|
| Relevant files | |||
|---|---|---|---|
| Enhancement |
|
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
||||||||||||||||||||||||
PR Code Suggestions ✨Latest suggestions up to cb468d4
Previous suggestionsSuggestions up to commit 2df9efa
Suggestions up to commit 9f58114
✅ Suggestions up to commit 89ed7c5
✅ Suggestions up to commit 60aabb3
✅ Suggestions up to commit b1f4b20
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Pull request overview
Updates scripts/format.sh to make it fast enough for local hooks by only running formatters for languages that changed relative to trunk (with an optional --lint mode).
Changes:
- Adds “smart targeting” by diffing
HEADvs trunk merge-base and conditionally running per-language formatters. - Adds
--lintflag to optionally run additional linters after formatting. - Adds an exit-1 check when formatters modify files (useful for CI/hooks), while always running buildifier + copyright.
3a7be8e to
60aabb3
Compare
bea8ed3 to
2ea60a8
Compare
|
I don't think you can run this with
If you remove |
766f57b to
9f58114
Compare
|
@cgoldberg formatters exit 0. We fail the script at the end if there is a diff not as a result of the failure. Presumably the linter failures can't be auto-fixed, so if there's a problem, I think fail-fast for that is ok locally. |
9f58114 to
2df9efa
Compare
With the Python change I put in yesterday, the linter can autofix something and will fail-fast (it will show what it fixed), so you won't see the diff at the end if it also made formatting changes. Not a big deal.. it's probably fine as-is. |
|
Yeah, it's a little muddled in rubocop as well since it can fix some linting things. hard to know exactly where to split these hairs. |
…x JavaScript casing
2df9efa to
cb468d4
Compare
Improve speed of format.sh so it can be used in pre-commit and pre-push hooks
🔗 Related Issues
independent of, but same implementation from Rake tasks in #17020 in format.sh
💥 What does this PR do?
Enhances
scripts/format.shwith smart targeting and an optional--lintflag:🔧 Implementation Notes
files call Rake tasks. Rake tasks should always be entry point and wrap other things to keep flow consistent.
💡 Additional Considerations
🔄 Types of changes