Skip to content

Commit

Permalink
[CI][format] Explicitly pass extensions to git-clang-format (take 2)
Browse files Browse the repository at this point in the history
This is a second attempt to land 7620fe0, which was reverted in 9572388
because it caused formatting not to be enforced for several patches.
  • Loading branch information
ldionne committed Jul 10, 2024
1 parent af21bc1 commit 8330366
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions llvm/utils/git/code-format-helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,17 @@ def format_run(self, changed_files: List[str], args: FormatArgs) -> Optional[str
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(",".join(extensions))

cf_cmd.append("--")
cf_cmd += cpp_files

Expand Down

0 comments on commit 8330366

Please sign in to comment.