Skip to content

Fix whitespace tooling edge cases#777

Open
johnml1135 wants to merge 1 commit intomainfrom
fix-whitespace-tooling
Open

Fix whitespace tooling edge cases#777
johnml1135 wants to merge 1 commit intomainfrom
fix-whitespace-tooling

Conversation

@johnml1135
Copy link
Contributor

@johnml1135 johnml1135 commented Mar 20, 2026

Summary

  • replace the invalid Unicode warning output in the whitespace checker with ASCII-safe text
  • handle clean-branch runs without requiring an existing check-results.log
  • fix the fallback diff invocation and prevent the wrapper from running the fixer after checker failures without results

Validation

  • ./Build/Agent/check-and-fix-whitespace.ps1
  • ./Build/Agent/commit-messages.ps1
  • CI: Full local check

This change is Reviewable

Copilot AI review requested due to automatic review settings March 20, 2026 18:27
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens the whitespace checking/fixing scripts against edge cases (invalid Unicode output, missing/empty results artifacts, and incorrect diff invocation) and adjusts the wrapper behavior to avoid running the fixer when the checker produced no usable output.

Changes:

  • Replaced Unicode warning output with ASCII-safe text in the whitespace checker.
  • Ensured check-results.log exists even when there are zero commits to report, and switched parsing to use the in-memory $log.
  • Adjusted diff invocation in the fixer and gated running the fixer based on checker outcome/artifacts.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
Build/Agent/fix-whitespace.ps1 Updates the fallback git diff call used to determine files to fix
Build/Agent/check-whitespace.ps1 Makes results logging resilient to empty output and replaces Unicode warning text
Build/Agent/check-and-fix-whitespace.ps1 Cleans stale results and gates fixer execution based on checker outcome

$base = Get-BaseRef
Write-Host "Fixing whitespace for files changed since $base..HEAD"
$fixFiles = git diff --name-only "$base"..HEAD
$fixFiles = git diff --name-only $base HEAD
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing from git diff <base>..<head> semantics to git diff <base> <head> can alter which changes/files are selected (notably when the base ref is not a strict ancestor, since A..B uses the merge-base). If the intent is still 'files changed since base', consider passing a single revision-range argument (e.g., \"$base..HEAD\") rather than two separate commit arguments.

Suggested change
$fixFiles = git diff --name-only $base HEAD
$fixFiles = git diff --name-only "$base..HEAD"

Copilot uses AI. Check for mistakes.
$null = $log | Tee-Object -FilePath check-results.log
$log | Out-Host
if (-not (Test-Path -LiteralPath 'check-results.log')) {
New-Item -ItemType File -Path 'check-results.log' -Force | Out-Null
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use -LiteralPath for New-Item here (to match Test-Path -LiteralPath and avoid provider/path parsing surprises). This keeps path handling consistent and reduces edge-case failures with special characters.

Suggested change
New-Item -ItemType File -Path 'check-results.log' -Force | Out-Null
New-Item -ItemType File -LiteralPath 'check-results.log' -Force | Out-Null

Copilot uses AI. Check for mistakes.
Comment on lines +11 to +16
if ($ec -eq 0 -or (Test-Path -LiteralPath 'check-results.log')) {
& "$PSScriptRoot/fix-whitespace.ps1"
}
else {
Write-Error 'Whitespace checker failed before producing results; skipping fixer.'
}
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using only file existence as a proxy for 'checker produced results' becomes less reliable now that the checker may create an empty check-results.log as a placeholder. To better match the intent ('skip fixer after failures without results'), consider checking for non-empty results (e.g., file length > 0) or using a more explicit success/results signal from the checker.

Copilot uses AI. Check for mistakes.
@github-actions
Copy link

NUnit Tests

    1 files  ±0      1 suites  ±0   5m 34s ⏱️ -15s
4 074 tests ±0  4 003 ✅ ±0  71 💤 ±0  0 ❌ ±0 
4 083 runs  ±0  4 012 ✅ ±0  71 💤 ±0  0 ❌ ±0 

Results for commit 26d1fa8. ± Comparison against base commit b6ac397.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants