Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions .github/workflows/pr-code-format.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
name: "Check code formatting"

permissions:
contents: read
contents: write
Copy link
Contributor

Choose a reason for hiding this comment

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

The base permission is "read" due to security concerns. There is a different job that reads output from "comments" file and posts giithub comment

Copy link
Contributor

Choose a reason for hiding this comment

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

"issue-write.yaml"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you, I saw in the debug output that the token only had read permissions, but I really couldn’t understand how, despite that, the workflow was able to create comments

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually LLM's can do a pretty good job finding this. I had the same question and claude code found it and explained very quickly.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe free-ones with code knowledge like deepwiki can do it too.

pull-requests: write
repository-projects: write

on:
pull_request:
Expand Down Expand Up @@ -37,8 +39,8 @@ jobs:
- name: Fetch code formatting utils
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
repository: ${{ github.repository }}
ref: ${{ github.base_ref }}
repository: localspook/llvm-project
ref: ${{ github.event.pull_request.head.ref }}
sparse-checkout: |
llvm/utils/git/requirements_formatting.txt
llvm/utils/git/code-format-helper.py
Expand Down Expand Up @@ -71,6 +73,7 @@ jobs:
run: pip install -r code-format-tools/llvm/utils/git/requirements_formatting.txt

- name: Run code formatter
id: run-code-formatter
env:
GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }}
CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
Expand All @@ -91,3 +94,10 @@ jobs:
name: workflow-args
path: |
comments

- uses: parkerbxyz/suggest-changes@00f556dcc0c9454336b598b8872fdc11d77984d9 #v3.0.0
if: failure()
with:
token: ${{ secrets.GITHUB_TOKEN }}
comment: "Formatting can be fixed by applying the following changes:"
event: "REQUEST_CHANGES"
7 changes: 5 additions & 2 deletions clang-tools-extra/clang-tidy/ClangTidy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -491,8 +491,11 @@ std::vector<std::string> ClangTidyASTConsumerFactory::getCheckNames() {
ClangTidyOptions::OptionMap ClangTidyASTConsumerFactory::getCheckOptions() {
ClangTidyOptions::OptionMap Options;
std::vector<std::unique_ptr<ClangTidyCheck>> Checks =
CheckFactories->createChecks(&Context);
for (const auto &Check : Checks)
CheckFactories->createChecks
(&Context);
for (const

auto &Check : Checks)
Check->storeOptions(Options);
return Options;
}
Expand Down
6 changes: 3 additions & 3 deletions llvm/utils/git/code-format-helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,10 @@ class ClangFormatHelper(FormatHelper):
friendly_name = "C/C++ code formatter"

def _construct_command(self, diff_expression: list[str] | None):
cf_cmd = [self.clang_fmt_path, "--diff"]
cf_cmd = [self.clang_fmt_path, "HEAD~1"]

if diff_expression:
cf_cmd.extend(diff_expression)
# if diff_expression:
# cf_cmd.extend(diff_expression)

# 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.
Expand Down
Loading