Skip to content

Commit ec88671

Browse files
committed
fix: correct dry-run change counts
1 parent 4d7787a commit ec88671

6 files changed

Lines changed: 56 additions & 12 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## [v1.5] - 2026-06-24
4+
5+
### Fixed
6+
7+
- Fixed dry-run summaries so they report the same files that a real run would change while still leaving file bytes untouched.
8+
39
## [v1.4] - 2026-06-21
410

511
### Fixed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ Dry run:
122122
```
123123
Would fix: src\Utils\StrTools.pas (mixed bytes; would save UTF-8 (BOM=Y, EOL=CRLF) (dry-run))
124124
OK : src\Main.dpr (UTF-8 OK)
125-
Done in 00:12.384. Files changed: 0. Failures: 0
125+
Done in 00:12.384. Files would change: 1. Failures: 0
126126
```
127127

128128
Actual run:
@@ -135,6 +135,7 @@ Done in 00:08.972. Files changed: 2. Failures: 0
135135
```
136136

137137
> When `silent` is enabled, normal output is suppressed, including the summary and JSON summary. In dry-run mode, change messages are phrased as “Would fix”.
138+
> Dry-run summaries count files that would change; JSON `changed` uses the same would-change count while leaving file bytes untouched.
138139
139140
---
140141

src/EncodingFixTool.dproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,19 +90,19 @@
9090
<SanitizedProjectName>EncodingFixTool</SanitizedProjectName>
9191
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
9292
<VerInfo_MajorVer>1</VerInfo_MajorVer>
93-
<VerInfo_MinorVer>4</VerInfo_MinorVer>
93+
<VerInfo_MinorVer>5</VerInfo_MinorVer>
9494
<VerInfo_Release>0</VerInfo_Release>
9595
<VerInfo_Build>0</VerInfo_Build>
9696
<VerInfo_Locale>1045</VerInfo_Locale>
97-
<VerInfo_Keys>CompanyName=;FileDescription=;FileVersion=1.4.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.4.0.0;Comments=;CFBundleName=</VerInfo_Keys>
97+
<VerInfo_Keys>CompanyName=;FileDescription=;FileVersion=1.5.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.5.0.0;Comments=;CFBundleName=</VerInfo_Keys>
9898
<DCC_Namespace>System;Xml;Data;Datasnap;Web;Soap;$(DCC_Namespace)</DCC_Namespace>
9999
<Icon_MainIcon>$(BDS)\bin\delphi_PROJECTICON.ico</Icon_MainIcon>
100100
<Icns_MainIcns>$(BDS)\bin\delphi_PROJECTICNS.icns</Icns_MainIcns>
101101
<DCC_ExeOutput>..\bin</DCC_ExeOutput>
102102
<CfgDependentOn>..\..\MaxLogicFoundation\MaxLogicDefault.optset</CfgDependentOn>
103103
</PropertyGroup>
104104
<PropertyGroup Condition="'$(Base_Android)'!=''">
105-
<VerInfo_Keys>package=com.embarcadero.$(MSBuildProjectName);label=$(MSBuildProjectName);versionCode=1;versionName=1.4.0;persistent=False;restoreAnyVersion=False;installLocation=auto;largeHeap=False;theme=TitleBar;hardwareAccelerated=true;apiKey=;minSdkVersion=23;targetSdkVersion=34</VerInfo_Keys>
105+
<VerInfo_Keys>package=com.embarcadero.$(MSBuildProjectName);label=$(MSBuildProjectName);versionCode=1;versionName=1.5.0;persistent=False;restoreAnyVersion=False;installLocation=auto;largeHeap=False;theme=TitleBar;hardwareAccelerated=true;apiKey=;minSdkVersion=23;targetSdkVersion=34</VerInfo_Keys>
106106
<BT_BuildType>Debug</BT_BuildType>
107107
<Android_LauncherIcon36>$(BDS)\bin\Artwork\Android\FM_LauncherIcon_36x36.png</Android_LauncherIcon36>
108108
<Android_LauncherIcon48>$(BDS)\bin\Artwork\Android\FM_LauncherIcon_48x48.png</Android_LauncherIcon48>
@@ -141,13 +141,13 @@
141141
<PropertyGroup Condition="'$(Base_Win32)'!=''">
142142
<DCC_Namespace>Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace)</DCC_Namespace>
143143
<BT_BuildType>Debug</BT_BuildType>
144-
<VerInfo_Keys>CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.4.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=$(MSBuildProjectName);ProductVersion=1.4.0.0;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName)</VerInfo_Keys>
144+
<VerInfo_Keys>CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.5.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=$(MSBuildProjectName);ProductVersion=1.5.0.0;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName)</VerInfo_Keys>
145145
<VerInfo_Locale>1033</VerInfo_Locale>
146146
</PropertyGroup>
147147
<PropertyGroup Condition="'$(Base_Win64)'!=''">
148148
<DCC_Namespace>Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace)</DCC_Namespace>
149149
<BT_BuildType>Debug</BT_BuildType>
150-
<VerInfo_Keys>CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.4.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=$(MSBuildProjectName);ProductVersion=1.4.0.0;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName)</VerInfo_Keys>
150+
<VerInfo_Keys>CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.5.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=$(MSBuildProjectName);ProductVersion=1.5.0.0;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName)</VerInfo_Keys>
151151
<VerInfo_Locale>1033</VerInfo_Locale>
152152
</PropertyGroup>
153153
<PropertyGroup Condition="'$(Cfg_1)'!=''">
@@ -177,7 +177,7 @@
177177
</PropertyGroup>
178178
<PropertyGroup Condition="'$(Cfg_2_Win32)'!=''">
179179
<VerInfo_Locale>1033</VerInfo_Locale>
180-
<VerInfo_Keys>CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.4.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=$(MSBuildProjectName);ProductVersion=1.4.0.0;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName)</VerInfo_Keys>
180+
<VerInfo_Keys>CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.5.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=$(MSBuildProjectName);ProductVersion=1.5.0.0;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName)</VerInfo_Keys>
181181
<Manifest_File>(None)</Manifest_File>
182182
<AppDPIAwarenessMode>none</AppDPIAwarenessMode>
183183
</PropertyGroup>

src/EncodingFixTool.res

0 Bytes
Binary file not shown.

src/EncodingFixToolCore.pas

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1524,6 +1524,7 @@ class function TEncodingFixTool.RunFromCommandLine: integer;
15241524
lStopwatch: TStopWatch;
15251525
lSilent: boolean;
15261526
lVerbose: boolean;
1527+
lChangedLabel: string;
15271528
lLoopProc: TProc<integer>;
15281529
lRoot: string;
15291530
begin
@@ -1595,10 +1596,7 @@ class function TEncodingFixTool.RunFromCommandLine: integer;
15951596
begin
15961597
if lChanged then
15971598
begin
1598-
if not lOptions.DryRun then
1599-
begin
1600-
lLocalChanged := 1;
1601-
end;
1599+
lLocalChanged := 1;
16021600
if (not lSilent) and (lOptions.OutputFormat = TOutputFormat.ofText) then
16031601
begin
16041602
TSafeConsole.WriteLine(Format('%s: %s (%s)',
@@ -1658,11 +1656,18 @@ class function TEncodingFixTool.RunFromCommandLine: integer;
16581656
[lScannedCount, lChangedCount, lSkippedCount, lFailureCount]));
16591657
end else if not lSilent then
16601658
begin
1659+
if lOptions.DryRun then
1660+
begin
1661+
lChangedLabel := 'Files would change';
1662+
end else begin
1663+
lChangedLabel := 'Files changed';
1664+
end;
16611665
TSafeConsole.WriteLine('');
1662-
TSafeConsole.WriteLine(Format('Done in %s. Files changed: %d. Failures: %d',
1666+
TSafeConsole.WriteLine(Format('Done in %s. %s: %d. Failures: %d',
16631667
[FormatDateTime('nn:ss.zzz', // pretty mm:ss.mmm
16641668
EncodeTime(0, lStopwatch.Elapsed.Minutes, lStopwatch.Elapsed.Seconds, lStopwatch.Elapsed.Milliseconds)
16651669
),
1670+
lChangedLabel,
16661671
lChangedCount,
16671672
lFailureCount]));
16681673
end;

tests/Invoke-EncodingFixTool.Tests.ps1

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ try {
136136
$lResult = Invoke-Tool @("path=$lRoot", 'recursive=n', 'ext=pas', 'eol=crlf', 'dry')
137137
Assert-True ($lResult.ExitCode -eq 0) "EOL dry-run should succeed."
138138
Assert-True ($lResult.Output -match 'Would fix: lfonly\.pas \(Would normalize EOL to CRLF \(dry-run\)\)') "Expected dry-run to report EOL-only normalization."
139+
Assert-True ($lResult.Output -match 'Files would change: 1') "Dry-run text summary should report would-change count."
139140

140141
$lBytes = [System.IO.File]::ReadAllBytes($lLfOnlyFile)
141142
Assert-True (($lBytes | Where-Object { $_ -eq 13 }).Count -eq 0) "Dry-run must not rewrite LF-only file."
@@ -172,6 +173,37 @@ try {
172173
$lJson = $lResult.Output | ConvertFrom-Json
173174
Assert-True (($lJson.scanned -eq 2) -and ($lJson.changed -eq 1) -and ($lJson.skipped -eq 1) -and ($lJson.failed -eq 0)) "Expected compact JSON summary counts for AI workflow."
174175

176+
$lDryJsonRoot = Join-Path $lRoot 'dry-json'
177+
New-Item -ItemType Directory -Path $lDryJsonRoot | Out-Null
178+
foreach ($i in 1..10) {
179+
[System.IO.File]::WriteAllBytes(
180+
(Join-Path $lDryJsonRoot "generated$i.pas"),
181+
[System.Text.Encoding]::ASCII.GetBytes("unit generated$i;`ninterface`nend.")
182+
)
183+
}
184+
185+
$lResult = Invoke-Tool @("path=$lDryJsonRoot", 'preset=delphi-ai', 'format=json', 'dry')
186+
Assert-True ($lResult.ExitCode -eq 0) "Dry-run JSON AI workflow should succeed."
187+
$lJson = $lResult.Output | ConvertFrom-Json
188+
Assert-True (($lJson.scanned -eq 10) -and ($lJson.changed -eq 10) -and ($lJson.skipped -eq 0) -and ($lJson.failed -eq 0)) "Dry-run JSON summary must count files that would change."
189+
190+
$lDryCrCount = 0
191+
Get-ChildItem -LiteralPath $lDryJsonRoot -Filter '*.pas' | ForEach-Object {
192+
$lDryCrCount += ([System.IO.File]::ReadAllBytes($_.FullName) | Where-Object { $_ -eq 13 }).Count
193+
}
194+
Assert-True ($lDryCrCount -eq 0) "Dry-run JSON workflow must not rewrite files."
195+
196+
$lResult = Invoke-Tool @("path=$lDryJsonRoot", 'preset=delphi-ai', 'format=json')
197+
Assert-True ($lResult.ExitCode -eq 0) "Real JSON AI workflow should succeed."
198+
$lJson = $lResult.Output | ConvertFrom-Json
199+
Assert-True (($lJson.scanned -eq 10) -and ($lJson.changed -eq 10) -and ($lJson.skipped -eq 0) -and ($lJson.failed -eq 0)) "Real JSON summary should match dry-run would-change count."
200+
201+
$lRealCrCount = 0
202+
Get-ChildItem -LiteralPath $lDryJsonRoot -Filter '*.pas' | ForEach-Object {
203+
$lRealCrCount += ([System.IO.File]::ReadAllBytes($_.FullName) | Where-Object { $_ -eq 13 }).Count
204+
}
205+
Assert-True ($lRealCrCount -eq 20) "Real JSON workflow should normalize the ten LF-only files."
206+
175207
$lGlobalRoot = Join-Path $lRoot 'global'
176208
New-Item -ItemType Directory -Path $lGlobalRoot | Out-Null
177209
[System.IO.File]::WriteAllBytes(

0 commit comments

Comments
 (0)