diff options
author | Louis Dionne <ldionne.2@gmail.com> | 2024-06-17 16:20:58 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-17 16:20:58 -0400 |
commit | 7620fe0d2d1e0257611c0ab0d96f3bf1bf7a1079 (patch) | |
tree | c0dc2cc4217de065ba64f282af21f9ff2fba918b | |
parent | 7ddff3a586baaf6f4403183ba51121951ce0602e (diff) | |
download | llvm-7620fe0d2d1e0257611c0ab0d96f3bf1bf7a1079.zip llvm-7620fe0d2d1e0257611c0ab0d96f3bf1bf7a1079.tar.gz llvm-7620fe0d2d1e0257611c0ab0d96f3bf1bf7a1079.tar.bz2 |
[CI][format] Explicitly pass extensions to git-clang-format (#95794)
This ensures that the CI script controls which file extensions are
considered instead of letting git-clang-format apply its own filtering
rules. In particular, this properly handles libc++ extension-less
headers which were passed to git-clang-format, but then dropped by that
tool as having an unrecognized extension.
-rwxr-xr-x | llvm/utils/git/code-format-helper.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/utils/git/code-format-helper.py b/llvm/utils/git/code-format-helper.py index f120702..d60d413 100755 --- a/llvm/utils/git/code-format-helper.py +++ b/llvm/utils/git/code-format-helper.py @@ -216,6 +216,17 @@ class ClangFormatHelper(FormatHelper): cf_cmd.append(args.start_rev) cf_cmd.append(args.end_rev) + # Gather the extension of all modified files and pass them explicitly to git-clang-format. + # This prevents git-clang-format from applying its own filtering rules on top of ours. + extensions = set() + for file in cpp_files: + _, ext = os.path.splitext(file) + extensions.add( + ext.strip(".") + ) # Exclude periods since git-clang-format takes extensions without them + cf_cmd.append("--extensions") + cf_cmd.append("'{}'".format(",".join(extensions))) + cf_cmd.append("--") cf_cmd += cpp_files |