-
-
Notifications
You must be signed in to change notification settings - Fork 41
Fix whitespace tooling edge cases #777
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,18 @@ | ||
| #!/usr/bin/env pwsh | ||
| $ErrorActionPreference = 'Continue' | ||
|
|
||
| if (Test-Path -LiteralPath 'check-results.log') { | ||
| Remove-Item -LiteralPath 'check-results.log' -Force | ||
| } | ||
|
|
||
| & "$PSScriptRoot/check-whitespace.ps1" | ||
| $ec = $LASTEXITCODE | ||
|
|
||
| & "$PSScriptRoot/fix-whitespace.ps1" | ||
| 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.' | ||
| } | ||
|
|
||
| exit $ec | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -38,6 +38,9 @@ Write-Host "Base ref: $baseRef ($baseSha)" | |||||
| $log = git log --check --pretty=format:'---% h% s' "$baseSha.." 2>&1 | ||||||
| $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 | ||||||
|
||||||
| New-Item -ItemType File -Path 'check-results.log' -Force | Out-Null | |
| New-Item -ItemType File -LiteralPath 'check-results.log' -Force | Out-Null |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -78,7 +78,7 @@ if (Test-Path -LiteralPath 'check-results.log') { | |||||
| if (-not $fixFiles -or $fixFiles.Count -eq 0) { | ||||||
| $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 | ||||||
|
||||||
| $fixFiles = git diff --name-only $base HEAD | |
| $fixFiles = git diff --name-only "$base..HEAD" |
There was a problem hiding this comment.
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.logas 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.