Skip to content

Commit

Permalink
πŸ› Fix formatting for c/c++
Browse files Browse the repository at this point in the history
The formatting commands incorrectly used [] instead of {}
in the fd glob expression. This caused it to match only single
characters instead of file extensions like cpp,cxx,hpp etc.
  • Loading branch information
abbec committed Nov 8, 2024
1 parent a71f7e6 commit eb8b20f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## Fixed
- C/C++ format commands used `[]` instead of `{}` in the fd glob
expression so it matched single chars.

## [5.0.0] - 2024-10-15

## Added
Expand Down
4 changes: 2 additions & 2 deletions c/make-derivation.nix
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ let
runHook preLint
if [ -z "''${dontCheckClangFormat:-}" ]; then
echo "🏟 Checking format in C/C++ files..."
${buildPackages.fd}/bin/fd --ignore-file=.gitignore --glob '*.[h,hpp,hh,cpp,cxx,cc,c]' --exec-batch clang-format -Werror -n --style=LLVM
${buildPackages.fd}/bin/fd --ignore-file=.gitignore --glob '*.{h,hpp,hh,cpp,cxx,cc,c}' --exec-batch clang-format -Werror -n --style=LLVM
rc=$?
if [ $rc -eq 0 ]; then
Expand All @@ -129,7 +129,7 @@ let
script = ''
runHook preFormat
echo "🏟️ Formatting C++ files..."
${buildPackages.fd}/bin/fd --glob '*.[h,hpp,hh,cpp,cxx,cc,c]' --exec-batch clang-format --style=LLVM -i "$@"
${buildPackages.fd}/bin/fd --glob '*.{h,hpp,hh,cpp,cxx,cc,c}' --exec-batch clang-format --style=LLVM -i "$@"
runHook postFormat
'';
description = "Format source code in the component.";
Expand Down

0 comments on commit eb8b20f

Please sign in to comment.