From 87a7446ffe81ce5f2f6b9689765bfbcf948a3321 Mon Sep 17 00:00:00 2001 From: Eltos Date: Wed, 13 Aug 2025 19:00:20 +0200 Subject: [PATCH 01/11] Auto-fix file format --- .github/workflows/format.yml | 43 ++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/format.yml diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 0000000..ce7cfdf --- /dev/null +++ b/.github/workflows/format.yml @@ -0,0 +1,43 @@ +name: Auto-fix file format + +# Since pre-commit.ci cannot run local hooks, run them here manually to fixup formatting in pull requests + +on: pull_request + +env: + # SSH Deploy Key with write access (needed to trigger push workflow runs in created pull request) + SSH_KEY: ${{ secrets.SSH_KEY_GITHUB_ACTION }} + +jobs: + pre-commit: + name: Format files with pre-commit + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v5 + with: + ssh-key: ${{ env.SSH_KEY }} + fetch-depth: 0 + + - name: Install python + uses: actions/setup-python@v3 + + - name: Install pre-commit + run: | + python3 -m pip install pre-commit + pre-commit install + + - name: Format files + continue-on-error: true + id: check + run: | + FILES=$(git diff --name-only HEAD origin/$GITHUB_BASE_REF | tr '\n' ' ') + echo $FILES + pre-commit run --files $FILES + + - name: Push formatted fixes + if: steps.check.outcome == 'failure' + run: | + git config user.name "Bot" + git config user.email "" + git commit -am "Fix file format [skip ci]" + git push origin HEAD:${{github.event.pull_request.head.ref}} From f053b293cfe539180ff677a7fcef92811eff72db Mon Sep 17 00:00:00 2001 From: Eltos Date: Wed, 13 Aug 2025 19:03:45 +0200 Subject: [PATCH 02/11] Test formatting issue --- PasteIntoFile/ClipboardContents.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/PasteIntoFile/ClipboardContents.cs b/PasteIntoFile/ClipboardContents.cs index 6a0893b..046b85c 100644 --- a/PasteIntoFile/ClipboardContents.cs +++ b/PasteIntoFile/ClipboardContents.cs @@ -814,7 +814,9 @@ public static ClipboardContents FromClipboard() { var images = new Dict(); // Generic image from file - if (Clipboard.ContainsFileDropList() && Clipboard.GetFileDropList() is StringCollection files && files.Count == 1) { + if ( Clipboard.ContainsFileDropList() && Clipboard.GetFileDropList() is StringCollection files && files.Count == 1) + + { var ext = BaseContent.NormalizeExtension(Path.GetExtension(files[0]).Trim('.')); if (ImageContentFromBytes(ext, File.ReadAllBytes(files[0])) is ImageLikeContent imageContent) images.Add(ext, imageContent); From 468ad4f103cf0a7a1a76761aceb68aa53b9e4b3f Mon Sep 17 00:00:00 2001 From: Eltos Date: Wed, 13 Aug 2025 19:20:39 +0200 Subject: [PATCH 03/11] skip if bot --- .github/workflows/format.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index ce7cfdf..85fa159 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -18,6 +18,15 @@ jobs: ssh-key: ${{ env.SSH_KEY }} fetch-depth: 0 + + - name: Skip if bot + run: | + AUTHOR=$(git log -1 --pretty=%an) + if [[ $AUTHOR =~ "bot|Bot" ]]; then + echo "Commit made by bot, skipping further steps in the pipeline." + exit 0 + fi + - name: Install python uses: actions/setup-python@v3 @@ -39,5 +48,5 @@ jobs: run: | git config user.name "Bot" git config user.email "" - git commit -am "Fix file format [skip ci]" + git commit -am "Fix file format" git push origin HEAD:${{github.event.pull_request.head.ref}} From f7353aca6695911323f88a8e117437f85a8a0b30 Mon Sep 17 00:00:00 2001 From: Bot Date: Wed, 13 Aug 2025 17:21:48 +0000 Subject: [PATCH 04/11] Fix file format --- PasteIntoFile/ClipboardContents.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/PasteIntoFile/ClipboardContents.cs b/PasteIntoFile/ClipboardContents.cs index 046b85c..6a0893b 100644 --- a/PasteIntoFile/ClipboardContents.cs +++ b/PasteIntoFile/ClipboardContents.cs @@ -814,9 +814,7 @@ public static ClipboardContents FromClipboard() { var images = new Dict(); // Generic image from file - if ( Clipboard.ContainsFileDropList() && Clipboard.GetFileDropList() is StringCollection files && files.Count == 1) - - { + if (Clipboard.ContainsFileDropList() && Clipboard.GetFileDropList() is StringCollection files && files.Count == 1) { var ext = BaseContent.NormalizeExtension(Path.GetExtension(files[0]).Trim('.')); if (ImageContentFromBytes(ext, File.ReadAllBytes(files[0])) is ImageLikeContent imageContent) images.Add(ext, imageContent); From 14747a2128d69ec8d210587fce3e46eb3d18d163 Mon Sep 17 00:00:00 2001 From: Eltos Date: Wed, 13 Aug 2025 19:26:43 +0200 Subject: [PATCH 05/11] bot --- .github/workflows/format.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 85fa159..53bcee2 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -22,7 +22,7 @@ jobs: - name: Skip if bot run: | AUTHOR=$(git log -1 --pretty=%an) - if [[ $AUTHOR =~ "bot|Bot" ]]; then + if [[ $AUTHOR =~ [Bb]ot ]]; then echo "Commit made by bot, skipping further steps in the pipeline." exit 0 fi From e5c5521eacf96cbb44a1f92ae3022f40cad94bad Mon Sep 17 00:00:00 2001 From: Eltos Date: Wed, 13 Aug 2025 19:27:47 +0200 Subject: [PATCH 06/11] test --- PasteIntoFile/ClipboardContents.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/PasteIntoFile/ClipboardContents.cs b/PasteIntoFile/ClipboardContents.cs index 6a0893b..9dd7bc9 100644 --- a/PasteIntoFile/ClipboardContents.cs +++ b/PasteIntoFile/ClipboardContents.cs @@ -836,8 +836,9 @@ public static ClipboardContents FromClipboard() { } // Image from encoded data uri - if (Clipboard.ContainsText()) { - var (mime_ext, bytes) = BytesFromDataUri(Clipboard.GetText()); + if (Clipboard.ContainsText()) + { + var (mime_ext, bytes) = BytesFromDataUri(Clipboard.GetText()); if (bytes != null && !images.ContainsKey(mime_ext)) if (ImageContentFromBytes(mime_ext, bytes) is ImageLikeContent imageContent) images.Add(mime_ext, imageContent); From 5dc856d3ea4bd9a9d2408f7d0876f2124cd2e43a Mon Sep 17 00:00:00 2001 From: Eltos Date: Wed, 13 Aug 2025 19:32:42 +0200 Subject: [PATCH 07/11] a --- .github/workflows/format.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 53bcee2..5f90824 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -22,6 +22,7 @@ jobs: - name: Skip if bot run: | AUTHOR=$(git log -1 --pretty=%an) + echo ">$AUTHOR<" if [[ $AUTHOR =~ [Bb]ot ]]; then echo "Commit made by bot, skipping further steps in the pipeline." exit 0 @@ -49,4 +50,4 @@ jobs: git config user.name "Bot" git config user.email "" git commit -am "Fix file format" - git push origin HEAD:${{github.event.pull_request.head.ref}} + git push From 923d3f7f22e7bb36fa7aff46e8274e9f7c9cebfe Mon Sep 17 00:00:00 2001 From: Eltos Date: Wed, 13 Aug 2025 19:43:07 +0200 Subject: [PATCH 08/11] a --- .github/workflows/format.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 5f90824..c09fb78 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -13,7 +13,7 @@ jobs: name: Format files with pre-commit runs-on: ubuntu-24.04 steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v4 with: ssh-key: ${{ env.SSH_KEY }} fetch-depth: 0 @@ -21,7 +21,8 @@ jobs: - name: Skip if bot run: | - AUTHOR=$(git log -1 --pretty=%an) + git log -1 + AUTHOR=$(git log -1 --pretty="%an %ae") echo ">$AUTHOR<" if [[ $AUTHOR =~ [Bb]ot ]]; then echo "Commit made by bot, skipping further steps in the pipeline." @@ -50,4 +51,5 @@ jobs: git config user.name "Bot" git config user.email "" git commit -am "Fix file format" + git config push.autoSetupRemote true git push From c889b74f4ffe40d76b0d1f43807e51fd20bdb01d Mon Sep 17 00:00:00 2001 From: Eltos Date: Wed, 13 Aug 2025 19:46:11 +0200 Subject: [PATCH 09/11] b --- .github/workflows/format.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index c09fb78..bcc0221 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -18,9 +18,9 @@ jobs: ssh-key: ${{ env.SSH_KEY }} fetch-depth: 0 - - name: Skip if bot run: | + git checkout ${{github.event.pull_request.head.ref}} git log -1 AUTHOR=$(git log -1 --pretty="%an %ae") echo ">$AUTHOR<" From d455fed43ae6ddd6398bdfbc86800f34bb9f6336 Mon Sep 17 00:00:00 2001 From: Eltos Date: Wed, 13 Aug 2025 19:54:39 +0200 Subject: [PATCH 10/11] j --- .github/workflows/format.yml | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index bcc0221..6449c82 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -13,40 +13,36 @@ jobs: name: Format files with pre-commit runs-on: ubuntu-24.04 steps: + - uses: actions/checkout@v4 with: ssh-key: ${{ env.SSH_KEY }} fetch-depth: 0 - - name: Skip if bot + - name: Install python + uses: actions/setup-python@v3 + + - name: Fix formatting + continue-on-error: true + id: format run: | git checkout ${{github.event.pull_request.head.ref}} - git log -1 + # Skip for commits created by bots (such as me) AUTHOR=$(git log -1 --pretty="%an %ae") - echo ">$AUTHOR<" if [[ $AUTHOR =~ [Bb]ot ]]; then - echo "Commit made by bot, skipping further steps in the pipeline." + echo "Commit made by $AUTHOR, skipping further steps in the pipeline." exit 0 fi - - - name: Install python - uses: actions/setup-python@v3 - - - name: Install pre-commit - run: | + # Install pre-commit python3 -m pip install pre-commit pre-commit install - - - name: Format files - continue-on-error: true - id: check - run: | - FILES=$(git diff --name-only HEAD origin/$GITHUB_BASE_REF | tr '\n' ' ') - echo $FILES - pre-commit run --files $FILES + # Format files + FILES=$(git diff --name-only HEAD origin/$GITHUB_BASE_REF | tr '\n' ' ') + echo $FILES + pre-commit run --files $FILES # non-zero exit code if files were modified - name: Push formatted fixes - if: steps.check.outcome == 'failure' + if: steps.format.outcome == 'failure' run: | git config user.name "Bot" git config user.email "" From a75a9dd69a2543743bb9bfe83083039f38f4bfb6 Mon Sep 17 00:00:00 2001 From: Bot Date: Wed, 13 Aug 2025 17:55:32 +0000 Subject: [PATCH 11/11] Fix file format --- PasteIntoFile/ClipboardContents.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/PasteIntoFile/ClipboardContents.cs b/PasteIntoFile/ClipboardContents.cs index 9dd7bc9..6a0893b 100644 --- a/PasteIntoFile/ClipboardContents.cs +++ b/PasteIntoFile/ClipboardContents.cs @@ -836,9 +836,8 @@ public static ClipboardContents FromClipboard() { } // Image from encoded data uri - if (Clipboard.ContainsText()) - { - var (mime_ext, bytes) = BytesFromDataUri(Clipboard.GetText()); + if (Clipboard.ContainsText()) { + var (mime_ext, bytes) = BytesFromDataUri(Clipboard.GetText()); if (bytes != null && !images.ContainsKey(mime_ext)) if (ImageContentFromBytes(mime_ext, bytes) is ImageLikeContent imageContent) images.Add(mime_ext, imageContent);