diff --git a/.github/workflows/clang-format-check.yml b/.github/workflows/clang-format-check.yml index 6d896fb1b69..5fe6cac3375 100644 --- a/.github/workflows/clang-format-check.yml +++ b/.github/workflows/clang-format-check.yml @@ -1,67 +1,85 @@ --- - name: ClangFormat Check - on: - push: - branches: - - main - - releasebranch_* - pull_request: - branches: - - main - - releasebranch_* - - "*" - concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: ${{ github.ref_protected != true }} - # permissions: {} - permissions: write-all - jobs: - formatting-check: - name: Formatting Check - runs-on: ubuntu-latest - # permissions: - # pull-requests: write - steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - - uses: DoozyX/clang-format-lint-action@11b773b1598aa4ae3b32f023701bca5201c3817d # v0.17 - with: - source: "." - clangFormatVersion: 15 - inplace: True - - name: Verify Changed files - uses: tj-actions/verify-changed-files@d774a4c7ebe335445d79c7b44138f56a76058ba0 # v19.0.0 - id: verify-changed-files - - run: echo '${{toJson(steps.verify-changed-files.outputs)}}' - - name: List all changed files tracked and untracked files - run: | - echo "Changed files: ${{ steps.verify-changed-files.outputs.changed_files }}" - - name: Add job summary without changed files - if: ${{ steps.verify-changed-files.outputs.files_changed == 'false' }} - run: | - { - echo "### Changed files:" - echo "No files were changed by clang-format" - } >> "$GITHUB_STEP_SUMMARY" - - name: Add job summary with changed files - if: ${{ steps.verify-changed-files.outputs.files_changed == 'true' }} - run: | - { - echo '### Changed files:' - echo '```' - echo '${{ steps.verify-changed-files.outputs.changed_files }}' - echo '```' - } >> "$GITHUB_STEP_SUMMARY" - - uses: parkerbxyz/suggest-changes@f5b10bcbfe35840153c0e823095d260d5abad1f9 # v1.0.0 - with: - comment: | - Please commit the suggested changes from clang-format. - - Suggestions can only be added to lines near lines changed in this PR. - - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - if: always() - with: - name: my-artifact - path: | - .clang-format - ${{ steps.verify-changed-files.outputs.changed_files }} - \ No newline at end of file +name: ClangFormat Check +on: + push: + branches: + - main + - releasebranch_* + pull_request: + branches: + - main + - releasebranch_* + - "*" +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.ref_protected != true }} +permissions: {} +jobs: + formatting-check: + name: Formatting Check + runs-on: ubuntu-latest + permissions: + contents: read + checks: write + issues: write + pull-requests: write + steps: + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - uses: DoozyX/clang-format-lint-action@11b773b1598aa4ae3b32f023701bca5201c3817d # v0.17 + with: + source: "." + clangFormatVersion: 15 + inplace: True + - name: Verify Changed files + uses: tj-actions/verify-changed-files@d774a4c7ebe335445d79c7b44138f56a76058ba0 # v19.0.0 + id: verify-changed-files + - id: git-changed-files + run: | + { + echo 'CHANGED_FILES<> "$GITHUB_OUTPUT" + - name: List all changed files tracked and untracked files + run: | + echo "Changed files: ${{ steps.git-changed-files.outputs.CHANGED_FILES }}" + - name: Add job summary without changed files + if: ${{ steps.verify-changed-files.outputs.files_changed == 'false' }} + run: | + { + echo "### Changed files:" + echo "No files were changed by clang-format" + } >> "$GITHUB_STEP_SUMMARY" + - name: Add job summary with changed files + if: ${{ steps.verify-changed-files.outputs.files_changed == 'true' }} + run: | + { + echo '### Changed files:' + echo '```' + echo "${CHANGED_FILES}" + echo '```' + } >> "$GITHUB_STEP_SUMMARY" + env: + CHANGED_FILES: ${{ steps.git-changed-files.outputs.CHANGED_FILES }} + - name: Add code suggestions + uses: reviewdog/action-suggester@3d7fde6859623ad6174df5fd662677a0eb63310a # v1.11.0 + with: + tool_name: clang-format + fail_on_error: true + cleanup: false + - name: Explain that more files need to be fixed + if: ${{ steps.verify-changed-files.outputs.files_changed == 'true' }} + run: | + { + echo '' + echo 'Suggestions can only be added near to lines changed in this PR.' + echo 'All these fixed files are included in the artifact. The artifact can be downloaded and copied to the the repository to replace unformatted files with the formatted files.' + } >> "$GITHUB_STEP_SUMMARY" + exit 1 + - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 + if: always() + with: + name: my-artifact + path: | + .clang-format + ${{ steps.git-changed-files.outputs.CHANGED_FILES }} diff --git a/db/db.copy/main.c b/db/db.copy/main.c index 5813cb18f35..bd8f80e7a2d 100644 --- a/db/db.copy/main.c +++ b/db/db.copy/main.c @@ -18,13 +18,13 @@ #include #include -int main(int argc, char **argv) -{ +int main(int argc, char * *argv) + { int ret; struct Option *from_driver, *from_database, *from_table; struct Option *to_driver, *to_database, *to_table; - struct Option *where, *select; - struct GModule *module; + struct Option * where, *select; + struct GModule * module ; const char *drv, *db; G_gisinit(argv[0]); diff --git a/file with spaces.c b/file with spaces.c new file mode 100644 index 00000000000..c6e030243e9 --- /dev/null +++ b/file with spaces.c @@ -0,0 +1,21 @@ +/**************************************************************************** + * + * MODULE: db.copy + * AUTHOR(S): Radim Blazek (original contributor) + * Glynn Clements , + * Markus Neteler + * PURPOSE: copy a table + * COPYRIGHT: (C) 2003-2006 by the GRASS Development Team + * + * This program is free software under the GNU General Public + * License (>=v2). Read the file COPYING that comes with GRASS + * for details. + * + *****************************************************************************/ + +#include + +int main(int argc, char **argv) +{ + int ret; +} \ No newline at end of file diff --git a/file with special some%0Athing.c b/file with special some%0Athing.c new file mode 100644 index 00000000000..c6e030243e9 --- /dev/null +++ b/file with special some%0Athing.c @@ -0,0 +1,21 @@ +/**************************************************************************** + * + * MODULE: db.copy + * AUTHOR(S): Radim Blazek (original contributor) + * Glynn Clements , + * Markus Neteler + * PURPOSE: copy a table + * COPYRIGHT: (C) 2003-2006 by the GRASS Development Team + * + * This program is free software under the GNU General Public + * License (>=v2). Read the file COPYING that comes with GRASS + * for details. + * + *****************************************************************************/ + +#include + +int main(int argc, char **argv) +{ + int ret; +} \ No newline at end of file diff --git a/file with special some;thing.c b/file with special some;thing.c new file mode 100644 index 00000000000..c6e030243e9 --- /dev/null +++ b/file with special some;thing.c @@ -0,0 +1,21 @@ +/**************************************************************************** + * + * MODULE: db.copy + * AUTHOR(S): Radim Blazek (original contributor) + * Glynn Clements , + * Markus Neteler + * PURPOSE: copy a table + * COPYRIGHT: (C) 2003-2006 by the GRASS Development Team + * + * This program is free software under the GNU General Public + * License (>=v2). Read the file COPYING that comes with GRASS + * for details. + * + *****************************************************************************/ + +#include + +int main(int argc, char **argv) +{ + int ret; +} \ No newline at end of file