33
44[CmdletBinding ()]
55param (
6- [string ]$TargetDir = $env: HOME ,
6+ [string ]$TargetDir = $ (if ($env: HOME ) { $env: HOME } else { $env: USERPROFILE }),
7+ [string ]$WorkspaceName = ' ' ,
78 [switch ]$Json ,
89 [switch ]$DryRun ,
910 [string ]$ApplyPatch = ' ' ,
@@ -150,7 +151,7 @@ function Check-ReadmeSections {
150151 } else {
151152 Emit- Result ' FAIL' ' README.md' ' Spec-kit section missing' $Dir
152153 }
153- if ($content -match ' (?im)^## .*Azubis' ) {
154+ if ($content -match ' (?im)^## .*( Azubis|Auszubildende) ' ) {
154155 Emit- Result ' PASS' ' README.md' ' Azubis section' $Dir
155156 } else {
156157 Emit- Result ' FAIL' ' README.md' ' Azubis section missing' $Dir
@@ -162,8 +163,10 @@ function Check-AnsiInScripts {
162163 $scriptsDir = Join-Path $Dir ' scripts'
163164 if (-not (Test-Path $scriptsDir )) { return }
164165 # ANSI escape scan: actual ESC byte, \033[, \e[ (PS1 uses .NET regex)
166+ # Exclude the scanner scripts themselves (they contain the patterns as literals in comments/code)
165167 $pattern = ' \x1b\[|\\033\[|\\e\['
166168 $found = Get-ChildItem - Path $scriptsDir - File - Recurse - ErrorAction SilentlyContinue |
169+ Where-Object { $_.Name -notmatch ' ^check-homogeneity\.(ps1|sh)$' } |
167170 Where-Object { (Get-Content $_.FullName - Raw - ErrorAction SilentlyContinue) -match $pattern } |
168171 Select-Object - First 1
169172 if ($null -eq $found ) {
@@ -289,14 +292,37 @@ foreach ($entry in $scanResults) {
289292 }
290293
291294 if ($level -eq 0 ) {
292- $canonicalHook = Join-Path $env: HOME ' scripts/hooks/pre-push'
295+ $canonicalHook = Join-Path $dir ' scripts/hooks/pre-push'
293296 if (Test-Path $canonicalHook ) {
294297 Emit- Result ' PASS' ' scripts/hooks/pre-push' ' canonical hook present' $dir
295298 } else {
296299 Emit- Result ' WARN' ' scripts/hooks/pre-push' ' canonical hook missing' $dir
297300 }
298301 }
299302
303+ # Level 0: Git Scope Isolation checks (GIT-SCOPE-001, GIT-SCOPE-002)
304+ if ($level -eq 0 ) {
305+ $homeDir2 = $ (if ($env: HOME ) { $env: HOME } else { $env: USERPROFILE })
306+ $gitconfigD2 = Join-Path $homeDir2 ' .gitconfig.d'
307+ $gitconfig2 = Join-Path $homeDir2 ' .gitconfig'
308+ if (-not (Test-Path $gitconfigD2 )) {
309+ if ($Json ) {
310+ Write-Host ' {"check":"GIT-SCOPE-001","status":"WARN","message":"~/.gitconfig.d/ fehlt — Scope-Isolierung nicht konfiguriert / missing — scope isolation not configured"}'
311+ }
312+ Emit- Result ' WARN' ' ~/.gitconfig.d/' `
313+ ' ~/.gitconfig.d/ fehlt — Scope-Isolierung nicht konfiguriert / missing — scope isolation not configured' `
314+ $dir
315+ } elseif (-not ((Get-Content $gitconfig2 - ErrorAction SilentlyContinue) |
316+ Select-String - SimpleMatch ' gitdir:~/home-baseline-tmp/' - Quiet)) {
317+ if ($Json ) {
318+ Write-Host ' {"check":"GIT-SCOPE-002","status":"WARN","message":"includeIf für home-baseline-tmp nicht gefunden / not found for home-baseline-tmp"}'
319+ }
320+ Emit- Result ' WARN' ' ~/.gitconfig' `
321+ ' includeIf für home-baseline-tmp nicht gefunden / not found for home-baseline-tmp' `
322+ $dir
323+ }
324+ }
325+
300326 # .editorconfig for C# Level-2 (FR-REV-E02)
301327 if ($level -eq 2 ) {
302328 Check- EditorconfigCsharp - Dir $dir
@@ -349,15 +375,15 @@ if ($Json) {
349375 $ls = if ($lt -gt 0 ) { [int ](($lp * 100 ) / $lt ) } else { 0 }
350376 $filled = [int ]($ls * 10 / 100 )
351377 $bar = (' █' * $filled ) + (' ░' * (10 - $filled ))
352- $shortName = $d -replace [regex ]::Escape($env: HOME ), ' ~'
378+ $shortName = $d -replace [regex ]::Escape($ ( if ( $ env: HOME) { $ env: HOME } else { $ env: USERPROFILE }) ), ' ~'
353379 Write-Host (" {0,-30} [{1}] {2,3} % ({3}/{4} checks)" -f $shortName , $bar , $ls , $lp , $lt )
354380 }
355381
356382 Write-Host " "
357383 Write-Host (" Overall: $OverallScore % | Workspaces: $WorkspacesCount | Projects: $ProjectsCount " )
358384
359385 if (-not $DryRun ) {
360- Write-Host " STATS.md updated: $env: HOME /STATS.md"
386+ Write-Host " STATS.md updated: $ ( if ( $ env: HOME) { $ env: HOME } else { $ env: USERPROFILE } ) /STATS.md"
361387 }
362388
363389 $fc = $Failures.Count ; $wc = $Warnings.Count
0 commit comments