Don't Panic and clang-tidy everything if there are no eligible files #78272
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.
Summary
None
Purpose of change
I was investigating some clang-tidy CI runs that were running over the whole repo and don't look like they should, and I found this logic/"y u do that coretutils" error.
Basically if there are no eligible files to tidy clang-tidy.sh thinks there's an error and then tidies everything instead of nothing.
The specific thing that happens is if you pass an empty string to grep (which means there are no lines to match against), grep thinks it's grep's fault and returns an error status.
Describe the solution
We're just calling grep to filter out paths in src/third-party, so it doesn't ned to be involved in that sanity check in the first place.
So capture the previous output to a variable and do the check, then filter out paths with "third-party" afterward.
After that filtering, if we end up with an empty string, exit (successfully) instead of running clang-tidy on everything.
Testing
I checked all the scripting logic locally, but I don't have a CI runner set up to test it fully.
Also as this is editing clang-tidy.sh that WILL trigger a tidy of everything, so check back some time tomorrow :/