From bd078094fee8f91f97a00bb820e24669ec39f67f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Sat, 20 Jan 2024 20:24:33 +0100 Subject: [PATCH 1/3] Ignore formatting commits in blame --- .git-blame-ignore-revs | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .git-blame-ignore-revs diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 0000000000..8e45a81202 --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1,2 @@ +27d409a89cb1607321404e0ebfe8bc0a63c337a3 +c80a961e5f0239a38b788ce86853bb79ed4e8651 From 4e23cc730ff2b31aaa9f29b04d2ea023fd06e8a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Sat, 20 Jan 2024 20:28:30 +0100 Subject: [PATCH 2/3] Reformat stray file --- Source/Managers/NetworkClient.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Managers/NetworkClient.cpp b/Source/Managers/NetworkClient.cpp index 23a5c2378f..2c9c84607a 100644 --- a/Source/Managers/NetworkClient.cpp +++ b/Source/Managers/NetworkClient.cpp @@ -842,7 +842,7 @@ namespace RTE { set_clip_rect(targetBitmap, targetBox.GetCorner().m_X, targetBox.GetCorner().m_Y, targetBox.GetCorner().m_X + targetBox.GetWidth() - 1, targetBox.GetCorner().m_Y + targetBox.GetHeight() - 1); // Choose the correct blitting function based on transparency setting - void (*pfBlit)(BITMAP* source, BITMAP* dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height) = m_BackgroundLayers[frame][i].DrawTrans ? &masked_blit : &blit; + void (*pfBlit)(BITMAP * source, BITMAP * dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height) = m_BackgroundLayers[frame][i].DrawTrans ? &masked_blit : &blit; // See if this SceneLayer is wider AND higher than the target bitmap; then use simple wrapping logic - otherwise need to tile if (m_BackgroundBitmaps[i]->w >= targetBitmap->w && m_BackgroundBitmaps[i]->h >= targetBitmap->h) { From d4e9b8c351507c8ecea7a7c492dcd127fc03aa0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Sat, 20 Jan 2024 20:52:32 +0100 Subject: [PATCH 3/3] Make CI add EOL to files which need it and post patch with changes --- .github/scripts/add-eol.sh | 3 +++ .github/workflows/clang-format.yml | 34 +++++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100755 .github/scripts/add-eol.sh diff --git a/.github/scripts/add-eol.sh b/.github/scripts/add-eol.sh new file mode 100755 index 0000000000..ce39143242 --- /dev/null +++ b/.github/scripts/add-eol.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +sed -e '$a\' "$@" diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml index 8ff45b6f72..f73a6d273f 100644 --- a/.github/workflows/clang-format.yml +++ b/.github/workflows/clang-format.yml @@ -35,10 +35,42 @@ jobs: - name: Run clang-format run: | - .github/scripts/run-clang-format.py -r Source Data/Base.rte/Shaders \ + .github/scripts/run-clang-format.py \ + -i \ + -r Source Data/Base.rte/Shaders \ --exclude Source/System/Base64 \ --exclude Source/System/BitMask \ --exclude Source/System/glad \ --exclude Source/System/MicroPather \ --exclude Source/System/Semver200 \ --exclude Source/System/StackWalker + - name: Add missing newlines + run: | + .github/scripts/run-clang-format.py \ + -i --clang-format-executable .github/scripts/add-eol.sh \ + -r Source Data/Base.rte/Shaders \ + --exclude Source/System/Base64 \ + --exclude Source/System/BitMask \ + --exclude Source/System/glad \ + --exclude Source/System/MicroPather \ + --exclude Source/System/Semver200 \ + --exclude Source/System/StackWalker + - name: Report changes + run: | + # Store the changes in a patch file first + git diff > clang-format-changes.patch + # if any changes were made, fail the build + if ! git diff --quiet ; then + echo "::error::Code misformatted. Run clang-format or apply the patch (printed below and attached to job summary) to fix." + # Print the changes to the console + cat clang-format-changes.patch + exit 1 + fi + - name: Upload artifacts + uses: actions/upload-artifact@v4 + # Only upload the patch file if the build failed, meaning that the code was not properly formatted + if: failure() + with: + name: clang-format-changes.patch + path: | + clang-format-changes.patch