forked from intel/intel-ai-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrevert_whitespace_files.ps1
More file actions
24 lines (20 loc) · 1006 Bytes
/
Copy pathrevert_whitespace_files.ps1
File metadata and controls
24 lines (20 loc) · 1006 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# PowerShell script to revert files with only minor changes (likely whitespace only)
# Get all modified files and their change stats
$modifiedFiles = git diff --name-only
Write-Host "Analyzing $($modifiedFiles.Count) files for whitespace-only changes..."
foreach ($file in $modifiedFiles) {
$stats = git diff --numstat $file
if ($stats) {
$parts = $stats.Split("`t")
$additions = [int]$parts[0]
$deletions = [int]$parts[1]
# If both additions and deletions are low and roughly equal, likely whitespace only
if ($additions -le 50 -and $deletions -le 50 -and [Math]::Abs($additions - $deletions) -le 20) {
Write-Host "Reverting whitespace-only file: $file ($additions additions, $deletions deletions)"
git checkout HEAD -- $file
} else {
Write-Host "Keeping real changes: $file ($additions additions, $deletions deletions)"
}
}
}
Write-Host "Done! Run 'git status' to see remaining changes."