From 4ed2f8c8b18cb7eda15aa89530da667a9f324930 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 14 Nov 2025 07:28:59 +0000 Subject: [PATCH 1/5] Initial plan From 6766ff1cf804faba1b52986004d7f79e48b69430 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 14 Nov 2025 07:33:27 +0000 Subject: [PATCH 2/5] Add GitHub Action for trailing whitespace check on PRs Co-authored-by: softworkz <4985349+softworkz@users.noreply.github.com> --- .../workflows/trailing-whitespace-check.yml | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 .github/workflows/trailing-whitespace-check.yml diff --git a/.github/workflows/trailing-whitespace-check.yml b/.github/workflows/trailing-whitespace-check.yml new file mode 100644 index 00000000..e00d1d02 --- /dev/null +++ b/.github/workflows/trailing-whitespace-check.yml @@ -0,0 +1,80 @@ +name: Trailing Whitespace Check + +on: + pull_request: + types: [opened, synchronize, reopened] + +jobs: + check-trailing-whitespace: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Check for trailing whitespace + run: | + echo "Checking for trailing whitespace in changed files..." + + # Get the base branch + BASE_SHA="${{ github.event.pull_request.base.sha }}" + HEAD_SHA="${{ github.event.pull_request.head.sha }}" + + # Get list of changed files (excluding deleted files) + CHANGED_FILES=$(git diff --name-only --diff-filter=d "$BASE_SHA" "$HEAD_SHA") + + if [ -z "$CHANGED_FILES" ]; then + echo "No files to check." + exit 0 + fi + + # File patterns to check (text files) + PATTERNS="\.cs$|\.csproj$|\.sln$|\.json$|\.yml$|\.yaml$|\.md$|\.sh$|\.ps1$|\.cmd$|\.txt$|\.xml$|\.config$|\.props$|\.targets$|\.js$|\.ts$|\.html$|\.css$|\.scss$" + + # Directories and file patterns to exclude + EXCLUDE_PATTERNS="(^|\/)(\.|node_modules|bin|obj|artifacts|packages|\.vs|\.nuke\/temp)($|\/)" + + ERRORS_FOUND=0 + TEMP_FILE=$(mktemp) + + while IFS= read -r file; do + # Skip if file doesn't exist (shouldn't happen with --diff-filter=d, but just in case) + if [ ! -f "$file" ]; then + continue + fi + + # Check if file matches patterns to check + if ! echo "$file" | grep -qE "$PATTERNS"; then + continue + fi + + # Check if file should be excluded + if echo "$file" | grep -qE "$EXCLUDE_PATTERNS"; then + continue + fi + + # Check for trailing whitespace + if grep -n '[[:space:]]$' "$file" > /dev/null 2>&1; then + echo "❌ Trailing whitespace found in: $file" + grep -n '[[:space:]]$' "$file" | head -10 + if [ $(grep -c '[[:space:]]$' "$file") -gt 10 ]; then + echo " ... and $(($(grep -c '[[:space:]]$' "$file") - 10)) more lines" + fi + echo "1" >> "$TEMP_FILE" + fi + done <<< "$CHANGED_FILES" + + ERRORS_FOUND=$(wc -l < "$TEMP_FILE" 2>/dev/null || echo "0") + rm -f "$TEMP_FILE" + + if [ "$ERRORS_FOUND" -gt 0 ]; then + echo "" + echo "❌ Found trailing whitespace in $ERRORS_FOUND file(s)." + echo "Please remove trailing whitespace from the files listed above." + exit 1 + else + echo "✅ No trailing whitespace found in changed files." + exit 0 + fi From 3090f44435c6c7e80d3342feee1d981bbd25932e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 14 Nov 2025 07:35:46 +0000 Subject: [PATCH 3/5] Add explicit permissions to trailing whitespace check workflow Co-authored-by: softworkz <4985349+softworkz@users.noreply.github.com> --- .github/workflows/trailing-whitespace-check.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/trailing-whitespace-check.yml b/.github/workflows/trailing-whitespace-check.yml index e00d1d02..59804218 100644 --- a/.github/workflows/trailing-whitespace-check.yml +++ b/.github/workflows/trailing-whitespace-check.yml @@ -7,6 +7,8 @@ on: jobs: check-trailing-whitespace: runs-on: ubuntu-latest + permissions: + contents: read steps: - name: Checkout code From 6f4e1f0b24b822e8c3bcb9fb6cd0412ec218ad00 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 14 Nov 2025 08:03:43 +0000 Subject: [PATCH 4/5] Simplify PATTERNS and add demo files with trailing whitespace Co-authored-by: softworkz <4985349+softworkz@users.noreply.github.com> --- .../workflows/trailing-whitespace-check.yml | 2 +- src/ElectronNET.CLI/TrailingWhitespaceDemo.cs | 24 +++++++++++++++++++ .../test-trailing-whitespace.html | 14 +++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 src/ElectronNET.CLI/TrailingWhitespaceDemo.cs create mode 100644 src/ElectronNET.WebApp/test-trailing-whitespace.html diff --git a/.github/workflows/trailing-whitespace-check.yml b/.github/workflows/trailing-whitespace-check.yml index 59804218..23b08fc3 100644 --- a/.github/workflows/trailing-whitespace-check.yml +++ b/.github/workflows/trailing-whitespace-check.yml @@ -33,7 +33,7 @@ jobs: fi # File patterns to check (text files) - PATTERNS="\.cs$|\.csproj$|\.sln$|\.json$|\.yml$|\.yaml$|\.md$|\.sh$|\.ps1$|\.cmd$|\.txt$|\.xml$|\.config$|\.props$|\.targets$|\.js$|\.ts$|\.html$|\.css$|\.scss$" + PATTERNS="\.cs$|\.csproj$|\.sln$|\.ts$|\.html$|\.css$|\.scss$" # Directories and file patterns to exclude EXCLUDE_PATTERNS="(^|\/)(\.|node_modules|bin|obj|artifacts|packages|\.vs|\.nuke\/temp)($|\/)" diff --git a/src/ElectronNET.CLI/TrailingWhitespaceDemo.cs b/src/ElectronNET.CLI/TrailingWhitespaceDemo.cs new file mode 100644 index 00000000..ad4f7c75 --- /dev/null +++ b/src/ElectronNET.CLI/TrailingWhitespaceDemo.cs @@ -0,0 +1,24 @@ +using System; + +namespace ElectronNET.TestDemo +{ + /// + /// This is a demo class to test trailing whitespace detection. + /// + public class TrailingWhitespaceDemo + { + // This line has trailing spaces at the end + private string demoField; + + public TrailingWhitespaceDemo() + { + demoField = "Hello World"; + } + + public void DemoMethod() + { + Console.WriteLine("This demonstrates the trailing whitespace check."); + // The workflow will detect these trailing spaces + } + } +} diff --git a/src/ElectronNET.WebApp/test-trailing-whitespace.html b/src/ElectronNET.WebApp/test-trailing-whitespace.html new file mode 100644 index 00000000..e417e6bc --- /dev/null +++ b/src/ElectronNET.WebApp/test-trailing-whitespace.html @@ -0,0 +1,14 @@ + + + + + Trailing Whitespace Test + + +

Demo Page

+

This file has trailing whitespace to demonstrate the check.

+
+ Content here +
+ + From 5d5bda02781adaf46e65501c2502ed6534cff4bb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 14 Nov 2025 08:22:01 +0000 Subject: [PATCH 5/5] Remove demo files with trailing whitespace Co-authored-by: softworkz <4985349+softworkz@users.noreply.github.com> --- src/ElectronNET.CLI/TrailingWhitespaceDemo.cs | 24 ------------------- .../test-trailing-whitespace.html | 14 ----------- 2 files changed, 38 deletions(-) delete mode 100644 src/ElectronNET.CLI/TrailingWhitespaceDemo.cs delete mode 100644 src/ElectronNET.WebApp/test-trailing-whitespace.html diff --git a/src/ElectronNET.CLI/TrailingWhitespaceDemo.cs b/src/ElectronNET.CLI/TrailingWhitespaceDemo.cs deleted file mode 100644 index ad4f7c75..00000000 --- a/src/ElectronNET.CLI/TrailingWhitespaceDemo.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; - -namespace ElectronNET.TestDemo -{ - /// - /// This is a demo class to test trailing whitespace detection. - /// - public class TrailingWhitespaceDemo - { - // This line has trailing spaces at the end - private string demoField; - - public TrailingWhitespaceDemo() - { - demoField = "Hello World"; - } - - public void DemoMethod() - { - Console.WriteLine("This demonstrates the trailing whitespace check."); - // The workflow will detect these trailing spaces - } - } -} diff --git a/src/ElectronNET.WebApp/test-trailing-whitespace.html b/src/ElectronNET.WebApp/test-trailing-whitespace.html deleted file mode 100644 index e417e6bc..00000000 --- a/src/ElectronNET.WebApp/test-trailing-whitespace.html +++ /dev/null @@ -1,14 +0,0 @@ - - - - - Trailing Whitespace Test - - -

Demo Page

-

This file has trailing whitespace to demonstrate the check.

-
- Content here -
- -