<# Verificare mecanica dupa implement, pentru workflow-ul roa-fix (pilot Archon). Pentru fiecare fisier dat (implicit: git diff --name-only HEAD + fisiere noi netracked, in ProjectRoot): 1. EF BF BD absent din tot fisierul (semnul coruperii cp1250/cp1252 -> UTF-8 replacement char). 2. Zero LF izolat (CRLF pe tot fisierul) - conteaza octeti pe disc, nu string decodat. 3. Pentru .vc2/.sc2: txt2vcx.ps1 -DryRun trebuie sa reuseasca (fidelity-check). Iesire: 0 daca toate fisierele trec toate verificarile; 1 la orice esec (cu motivul pe fisier). #> param( [string]$ProjectRoot = "D:\roa\roacont", [string[]]$Files ) $ErrorActionPreference = "Stop" Set-Location $ProjectRoot # -Files explicit => comportamentul istoric (fara fisier de verificat, exit 0) $explicitFiles = $PSBoundParameters.ContainsKey('Files') if (-not $Files -or $Files.Count -eq 0) { $tracked = git diff --name-only HEAD 2>$null $untracked = git ls-files --others --exclude-standard 2>$null # COMUN e repo git separat, exclus din repo-ul proiectului $comun = @(git -C COMUN diff --name-only HEAD 2>$null) + @(git -C COMUN ls-files --others --exclude-standard 2>$null) | Where-Object { $_ } | Where-Object { $_ -match ".(prg|vc2|sc2|fr2|mn2|h)$" } | ForEach-Object { "COMUN/$_" } $Files = @($tracked) + @($untracked) + @($comun) | Where-Object { $_ -match ".(prg|vc2|sc2|fr2|mn2|h)$" } | Sort-Object -Unique } if (-not $Files -or $Files.Count -eq 0) { if ($explicitFiles) { Write-Output "Niciun fisier modificat - nimic de verificat." exit 0 } Write-Output "Niciun fisier modificat - implementarea nu a produs diff." exit 1 } $failures = @() foreach ($f in $Files) { $full = Join-Path $ProjectRoot $f if (-not (Test-Path $full)) { Write-Output "SKIP $f (sters sau inexistent)" continue } $bytes = [IO.File]::ReadAllBytes($full) # 1. EF BF BD absent $badSeq = 0 for ($i = 0; $i -lt $bytes.Length - 2; $i++) { if ($bytes[$i] -eq 0xEF -and $bytes[$i+1] -eq 0xBF -and $bytes[$i+2] -eq 0xBD) { $badSeq++ } } if ($badSeq -gt 0) { $failures += "$f : $badSeq octet(i) EF BF BD (corupere cp1250/cp1252 -> UTF-8 replacement char)" continue } # 2. CRLF pe tot fisierul (zero LF izolat) $lf = 0; $crlf = 0 for ($i = 0; $i -lt $bytes.Length; $i++) { if ($bytes[$i] -eq 0x0A) { $lf++ if ($i -gt 0 -and $bytes[$i-1] -eq 0x0D) { $crlf++ } } } $isolated = $lf - $crlf if ($isolated -ne 0) { $failures += "$f : $isolated LF izolat (fisierul nu mai e CRLF pe tot)" continue } # 3. txt2vcx.ps1 -DryRun pentru .vc2/.sc2 $ext = [IO.Path]::GetExtension($f).ToLowerInvariant() if ($ext -eq ".vc2" -or $ext -eq ".sc2") { # tintele de sub COMUN\ cer -AllowComun (DryRun nu scrie nimic) $argv = @('-ExecutionPolicy', 'Bypass', '-File', 'D:\ROA\UTIL\foxbin2prg\txt2vcx.ps1', '-TextFile', $full, '-ProjectRoot', $ProjectRoot, '-CacheRoot', $ProjectRoot, '-DryRun') if ($f -match '^COMUN[\\/]') { $argv += '-AllowComun' } & powershell $argv 2>&1 | Out-Null if ($LASTEXITCODE -ne 0) { $failures += "$f : txt2vcx.ps1 -DryRun a esuat (exit $LASTEXITCODE)" continue } } Write-Output "OK $f" } if ($failures.Count -gt 0) { Write-Output "--- ESECURI ---" $failures | ForEach-Object { Write-Output $_ } exit 1 } Write-Output "Toate fisierele au trecut verificarile." exit 0