diff --git a/.github/workflows/pr-code-format.yml b/.github/workflows/pr-code-format.yml index 9396bf019e1ac..e2f67dcc65c81 100644 --- a/.github/workflows/pr-code-format.yml +++ b/.github/workflows/pr-code-format.yml @@ -1,7 +1,9 @@ name: "Check code formatting" permissions: - contents: read + contents: write + pull-requests: write + repository-projects: write on: pull_request: @@ -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 @@ -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 }} @@ -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" diff --git a/clang-tools-extra/clang-tidy/ClangTidy.cpp b/clang-tools-extra/clang-tidy/ClangTidy.cpp index 4c36bbccf44d9..ca50e9bffd591 100644 --- a/clang-tools-extra/clang-tidy/ClangTidy.cpp +++ b/clang-tools-extra/clang-tidy/ClangTidy.cpp @@ -491,8 +491,11 @@ std::vector ClangTidyASTConsumerFactory::getCheckNames() { ClangTidyOptions::OptionMap ClangTidyASTConsumerFactory::getCheckOptions() { ClangTidyOptions::OptionMap Options; std::vector> Checks = - CheckFactories->createChecks(&Context); - for (const auto &Check : Checks) + CheckFactories->createChecks + (&Context); + for (const + + auto &Check : Checks) Check->storeOptions(Options); return Options; } diff --git a/llvm/utils/git/code-format-helper.py b/llvm/utils/git/code-format-helper.py index 7a5311d668f79..6a6ae438427f7 100755 --- a/llvm/utils/git/code-format-helper.py +++ b/llvm/utils/git/code-format-helper.py @@ -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.