Skip to content
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

pre-commit: code formatter fixes #4415

Merged
merged 10 commits into from
Mar 16, 2021

Conversation

jepler
Copy link
Member

@jepler jepler commented Mar 15, 2021

This adds the "no-run-if-empty" flag to the xargs invocation. Otherwise, if git diff names no files, the command is run once with no agument specified which leads to running on a default list of files that appears to include ignored files and files in submodules.

I am uneasy about how this works (it means that pre-commit run --all doesn't actually check all files) but that's a separate issue.

Change the pre-commit setup so that codeformat.py contains the list of files to run on, according to pre-commit's usual rules

This adds the "no-run-if-empty" flag to the xargs invocation.  Otherwise,
if git diff names no files, the command is run once with no agument
specified which leads to running on a default list of files that appears
to include ignored files and files in submodules.

I am uneasy about how this works (it means that `pre-commit run --all`
doesn't actually check all files) but that's a separate issue.
@jepler jepler requested a review from microdev1 March 15, 2021 20:20
@jepler
Copy link
Member Author

jepler commented Mar 15, 2021

This isn't right either, because during CI we appear to depend on exactly this behavior to run the formatting at all.

@jepler jepler changed the title pre-commit: only run uncrustify if changed files are detected pre-commit: let pre-commit control which files codeformat.py runs on Mar 15, 2021
@jepler
Copy link
Member Author

jepler commented Mar 15, 2021

The build failed at "pre-commit: Have pre-commit pass the list of files to codeformat.py" ( cc1dd73 ) so I added all the changes that the formatter made locally.

@jepler jepler force-pushed the pre-commit-no-run-if-empty branch from 2567bdd to d3bf1fe Compare March 15, 2021 23:12
@jepler jepler changed the title pre-commit: let pre-commit control which files codeformat.py runs on pre-commit: code formatter fixes Mar 16, 2021
Copy link
Collaborator

@microdev1 microdev1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple nitpicks otherwise the changes look good. Thanks!

BUILDING.md Show resolved Hide resolved
tools/codeformat.py Show resolved Hide resolved
@jepler jepler merged commit bc690d4 into adafruit:main Mar 16, 2021
@jepler jepler deleted the pre-commit-no-run-if-empty branch November 3, 2021 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants