Skip to content

Conversation

@sbmueller
Copy link
Contributor

@sbmueller sbmueller commented Dec 10, 2024

The clang-format logic relied on copying the config file into the repo root, which pollutes the repository and might fail if there is already a symlink. This change modifies the logic to directly pass the config location to the clang-format CLI.

Tested in starling-core:

bazel run @rules_swiftnav//clang_format
INFO: Analyzed target @rules_swiftnav//clang_format:clang_format (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target @rules_swiftnav//clang_format:clang_format up-to-date:
  bazel-bin/external/rules_swiftnav/clang_format/clang_format
INFO: Elapsed time: 0.255s, Critical Path: 0.12s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
INFO: Running command line: bazel-bin/external/rules_swiftnav/clang_format/clang_format format_diff external/aarch64-darwin-llvm/bin/clang-format external/rules_swiftnav/clang_format/.clang-format

@sbmueller sbmueller requested a review from armallen December 10, 2024 14:32
@sbmueller sbmueller requested a review from a team as a code owner December 10, 2024 14:32
@sbmueller sbmueller changed the title clang-format: Use config directly instead of modifying repository clang-format: Use config directly instead of modifying repository [AP-3053] Dec 10, 2024
Copy link
Contributor

@armallen armallen left a comment

Choose a reason for hiding this comment

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

Thanks for looking into this 🚀

fi
git ls-files '*.[ch]' '*.cpp' '*.cxx' '*.cc' '*.hpp' '*.hxx' \
| xargs -r $CLANG_FORMAT_BIN -i
| xargs -r $CLANG_FORMAT_BIN -i --style=file:$CLANG_FORMAT_CONFIG
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: ShellCheck reports several issues in this script (missing double quotes around all variables, uses of backquotes), which might be worth fixing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cool linter! I've fixed all the smells.

@sbmueller sbmueller merged commit e1db23f into main Dec 10, 2024
1 check passed
@sbmueller sbmueller deleted the smuller/AP-3053-clang-tools branch December 10, 2024 16:56
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.

3 participants