BUG: Fail the check when no files are marked for clang-format - #24
Merged
Merged
Conversation
clang-format.bash formats only tracked files whose hooks.style Git attribute includes clangformat. In a repository without such a .gitattributes entry no file is selected, and the script then runs "clang-format -i" with no file arguments. clang-format prints "error: cannot use -i when reading from stdin." but exits 0, so the check reported success without checking anything. Count the matching files first, fail with instructions for adding a .gitattributes when there are none, and log how many files are checked. Document the .gitattributes requirement in the README. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015k1PExcmd3DPt9VFSGGmcL
hjmjohnson
approved these changes
Sep 29, 2026
Member
Author
|
We should test this with some remote modules, before we forget about it. |
Member
Author
|
Works as expected in InsightSoftwareConsortium/ITKThinShellDemons#27. |
dzenanz
added a commit
to InsightSoftwareConsortium/ITKModuleTemplate
that referenced
this pull request
Sep 29, 2026
See InsightSoftwareConsortium/ITKClangFormatLinterAction#24 File taken from InsightSoftwareConsortium/ITKThinShellDemons#27 Note: the module template no longer passes it, so remove clang-format-linter.yml from here.
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.
clang-format.bash formats only tracked files whose hooks.style Git attribute includes clangformat. In a repository without such a .gitattributes entry no file is selected, and the script then runs "clang-format -i" with no file arguments. clang-format prints "error: cannot use -i when reading from stdin." but exits 0, so the check reported success without checking anything.
Count the matching files first, fail with instructions for adding a .gitattributes when there are none, and log how many files are checked. Document the .gitattributes requirement in the README.