Skip to content

BUG: Fail the check when no files are marked for clang-format - #24

Merged
hjmjohnson merged 1 commit into
mainfrom
fail-on-empty-file-list
Sep 29, 2026
Merged

hjmjohnson merged 1 commit into
mainfrom
fail-on-empty-file-list

Conversation

@dzenanz

@dzenanz dzenanz commented Sep 23, 2026

Copy link
Copy Markdown
Member

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.

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
@dzenanz
dzenanz requested a review from hjmjohnson September 23, 2026 20:26
@hjmjohnson
hjmjohnson merged commit fc9d686 into main Sep 29, 2026
@dzenanz
dzenanz deleted the fail-on-empty-file-list branch September 29, 2026 16:55
@dzenanz

dzenanz commented Sep 29, 2026

Copy link
Copy Markdown
Member Author

We should test this with some remote modules, before we forget about it.

@dzenanz

dzenanz commented Sep 29, 2026

Copy link
Copy Markdown
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants