1+ $ErrorActionPreference = " Stop"
2+ $hasBlockingIssue = $false
3+
4+ function Write-Section ($title ) {
5+ Write-Host " "
6+ Write-Host " [$title ]" - ForegroundColor Yellow
7+ }
8+
9+ function Flag-Blocking ($message ) {
10+ Write-Host $message - ForegroundColor Red
11+ $script :hasBlockingIssue = $true
12+ }
13+
14+ Write-Host " "
15+ Write-Host " === SkunkScrape Commit Readiness Check ===" - ForegroundColor Cyan
16+
17+ Write-Section " Tooling"
18+ if (Get-Command python - ErrorAction SilentlyContinue) {
19+ python -- version
20+ } else {
21+ Flag- Blocking " Python not found on PATH."
22+ }
23+
24+ if (Get-Command git - ErrorAction SilentlyContinue) {
25+ git -- version
26+ } else {
27+ Flag- Blocking " Git not found on PATH."
28+ }
29+
30+ Write-Section " Key Files"
31+ $requiredPaths = @ (
32+ " .\main.py" ,
33+ " .\pyproject.toml" ,
34+ " .\README.md" ,
35+ " .\skunkscrape\plugins\manifest.json" ,
36+ " .\tests\test_manifest.py" ,
37+ " .\tests\test_smart_contact_crawler.py" ,
38+ " .\tests\test_main.py"
39+ )
40+
41+ foreach ($path in $requiredPaths ) {
42+ if (Test-Path $path ) {
43+ Write-Host " [OK] $path " - ForegroundColor Green
44+ } else {
45+ Flag- Blocking " [MISS] $path "
46+ }
47+ }
48+
49+ Write-Section " Pytest"
50+ try {
51+ python - m pytest
52+ if ($LASTEXITCODE -eq 0 ) {
53+ Write-Host " Test suite passed." - ForegroundColor Green
54+ } else {
55+ Flag- Blocking " Test suite failed."
56+ }
57+ }
58+ catch {
59+ Flag- Blocking " Pytest execution failed: $ ( $_.Exception.Message ) "
60+ }
61+
62+ Write-Section " Merge Conflict Markers"
63+ $conflicts = git grep -nE ' ^(<<<<<<<|=======|>>>>>>>)' 2> $null
64+ if ($conflicts ) {
65+ Flag- Blocking " Merge conflict markers found:"
66+ $conflicts | ForEach-Object { Write-Host $_ - ForegroundColor Red }
67+ } else {
68+ Write-Host " No merge conflict markers found." - ForegroundColor Green
69+ }
70+
71+ Write-Section " README Sanity Check"
72+ if (Test-Path " .\README.md" ) {
73+ $readmeHead = Get-Content " .\README.md" - TotalCount 5
74+ $looksWrong = $false
75+
76+ foreach ($line in $readmeHead ) {
77+ if ($line -match ' ^\s*(import |from\s+\w+\s+import )' ) {
78+ $looksWrong = $true
79+ }
80+ }
81+
82+ if ($looksWrong ) {
83+ Flag- Blocking " README.md appears to contain Python code instead of markdown."
84+ } else {
85+ Write-Host " README.md looks sane." - ForegroundColor Green
86+ }
87+ }
88+
89+ Write-Section " Tracked Artefact Risk"
90+ $artefactPaths = @ (
91+ " .\__pycache__" ,
92+ " .\skunkscrape.egg-info" ,
93+ " .\.pytest_cache" ,
94+ " .\data\logs" ,
95+ " .\data\output"
96+ )
97+
98+ foreach ($path in $artefactPaths ) {
99+ if (Test-Path $path ) {
100+ Write-Host " [WARN] Present: $path " - ForegroundColor DarkYellow
101+ }
102+ }
103+
104+ Write-Section " Git Status"
105+ $gitStatus = git status -- short
106+ if ($gitStatus ) {
107+ $gitStatus | ForEach-Object { Write-Host $_ }
108+ } else {
109+ Write-Host " Working tree clean." - ForegroundColor Green
110+ }
111+
112+ Write-Section " Ignored Files Check"
113+ $ignored = git status -- ignored -- short 2> $null
114+ if ($ignored ) {
115+ Write-Host " Ignored file summary available." - ForegroundColor DarkGray
116+ } else {
117+ Write-Host " No ignored file output." - ForegroundColor DarkGray
118+ }
119+
120+ Write-Host " "
121+ if ($hasBlockingIssue ) {
122+ Write-Host " Commit readiness check completed with blocking issues." - ForegroundColor Red
123+ exit 1
124+ } else {
125+ Write-Host " Commit readiness check passed." - ForegroundColor Green
126+ exit 0
127+ }
0 commit comments