#!/usr/bin/env pwsh <# .SYNOPSIS Verifies the Module 05 challenge solution. .DESCRIPTION This script checks that: - The challenge directory exists - A Git repository exists - No merge conflicts remain - The merge was completed successfully - Conflict markers have been removed from files #> Write-Host "`n=== Verifying Module 05 Solution ===" -ForegroundColor Cyan $allChecksPassed = $true # Check if challenge directory exists if (-not (Test-Path "challenge")) { Write-Host "[FAIL] Challenge directory not found. Did you run setup.ps1?" -ForegroundColor Red exit 1 } Set-Location "challenge" # Check if git repository exists if (-not (Test-Path ".git")) { Write-Host "[FAIL] Not a git repository. Did you run setup.ps1?" -ForegroundColor Red Set-Location .. exit 1 } # Check current branch is main $currentBranch = git branch --show-current 2>$null if ($currentBranch -eq "main") { Write-Host "[PASS] Currently on main branch" -ForegroundColor Green } else { Write-Host "[FAIL] Not on main branch (currently on: $currentBranch)" -ForegroundColor Red Write-Host "[HINT] Switch to main with: git checkout main" -ForegroundColor Yellow $allChecksPassed = $false } # Check if there are any unresolved conflicts $gitStatus = git status --porcelain 2>$null $hasConflicts = git status | Select-String "Unmerged paths" 2>$null if ($hasConflicts) { Write-Host "[FAIL] Unresolved merge conflicts still exist" -ForegroundColor Red Write-Host "[HINT] Open app.py, resolve conflicts, then: git add app.py && git commit" -ForegroundColor Yellow $allChecksPassed = $false } else { Write-Host "[PASS] No unresolved conflicts" -ForegroundColor Green } # Check if app.py exists if (-not (Test-Path "app.py")) { Write-Host "[FAIL] app.py not found" -ForegroundColor Red Write-Host "[HINT] Did you run setup.ps1?" -ForegroundColor Yellow $allChecksPassed = $false Set-Location .. exit 1 } # Check if app.py contains conflict markers $appContent = Get-Content "app.py" -Raw if ($appContent -match "<<<<<<< HEAD" -or $appContent -match "=======" -or $appContent -match ">>>>>>>") { Write-Host "[FAIL] Conflict markers still present in app.py" -ForegroundColor Red Write-Host "[HINT] Edit app.py to remove all conflict markers (<<<<<<< ======= >>>>>>>)" -ForegroundColor Yellow $allChecksPassed = $false } else { Write-Host "[PASS] No conflict markers in app.py" -ForegroundColor Green } # Check if a merge commit exists $mergeCommits = git log --merges --oneline 2>$null if ($mergeCommits) { Write-Host "[PASS] Merge commit exists (conflict was resolved and committed)" -ForegroundColor Green } else { # Check if we're in the middle of a merge if (Test-Path ".git/MERGE_HEAD") { Write-Host "[FAIL] Merge not completed - still in progress" -ForegroundColor Red Write-Host "[HINT] After resolving conflicts and staging with 'git add', run 'git commit'" -ForegroundColor Yellow $allChecksPassed = $false } else { Write-Host "[FAIL] No merge commit found" -ForegroundColor Red Write-Host "[HINT] Did you merge feature-updates into main?" -ForegroundColor Yellow $allChecksPassed = $false } } # Check that file has actual content (not just conflict markers removed) if ($appContent -match "def main\(\):" -and $appContent -match "print") { Write-Host "[PASS] app.py contains valid Python code" -ForegroundColor Green } else { Write-Host "[FAIL] app.py appears to be incomplete or damaged" -ForegroundColor Red $allChecksPassed = $false } Set-Location .. # Final summary if ($allChecksPassed) { Write-Host "`n" -NoNewline Write-Host "=====================================" -ForegroundColor Green Write-Host " CONGRATULATIONS! CHALLENGE PASSED!" -ForegroundColor Green Write-Host "=====================================" -ForegroundColor Green Write-Host "`nYou've successfully resolved a merge conflict!" -ForegroundColor Cyan Write-Host "You now understand:" -ForegroundColor Cyan Write-Host " - How merge conflicts occur (same lines changed differently)" -ForegroundColor White Write-Host " - How to recognize conflict markers" -ForegroundColor White Write-Host " - How to manually resolve conflicts" -ForegroundColor White Write-Host " - How to complete a merge after resolution (git add + git commit)" -ForegroundColor White Write-Host "`nThis is a crucial skill for collaborative development!" -ForegroundColor Green Write-Host "Ready for the next module!" -ForegroundColor Green Write-Host "" } else { Write-Host "`n[SUMMARY] Some checks failed. Review the hints above and try again." -ForegroundColor Red Write-Host "[INFO] You can run this verification script as many times as needed." -ForegroundColor Yellow Write-Host "[TIP] If stuck, run 'git status' to see what state you're in." -ForegroundColor Cyan Write-Host "" exit 1 }