#!/usr/bin/env pwsh <# .SYNOPSIS Verifies the Module 01 challenge solution. .DESCRIPTION Checks if the student has correctly: - Initialized a git repository - Created at least one commit - Committed both required files (welcome.txt and instructions.txt) #> . "$PSScriptRoot\..\..\util.ps1" Write-Host "Verifying Module 01: Git Basics Challenge..." -ForegroundColor Cyan Write-Host "" $allChecksPassed = $true $challengeRoot = "$PSScriptRoot\challenge" # Check if challenge directory exists if (-not (Test-Path $challengeRoot)) { Write-Fail "Challenge directory not found. Run setup.ps1 first." -ForegroundColor Red exit 1 } # Check if git repository exists if (-not (Test-Path "$challengeRoot\.git")) { Write-Fail "No git repository found. Did you run 'git init'?" -ForegroundColor Red exit 1 } Write-Pass "Git repository initialized" -ForegroundColor Green # Check if there are any commits $commitCount = (git rev-list --all --count 2>$null) if ($null -eq $commitCount -or $commitCount -eq 0) { Write-Fail "No commits found. Have you committed your changes?" -ForegroundColor Red $allChecksPassed = $false } else { Write-Pass "Found $commitCount commit(s)" -ForegroundColor Green } # Check if both files are in the git history using git ls-tree if ($commitCount -gt 0) { $trackedFiles = git ls-tree -r HEAD --name-only 2>$null if ($trackedFiles -match "welcome.txt") { Write-Pass "welcome.txt is committed" -ForegroundColor Green } else { Write-Fail "welcome.txt is not in the commit history" -ForegroundColor Red $allChecksPassed = $false } if ($trackedFiles -match "instructions.txt") { Write-Pass "instructions.txt is committed" -ForegroundColor Green } else { Write-Fail "instructions.txt is not in the commit history" -ForegroundColor Red $allChecksPassed = $false } } # Check for uncommitted changes $statusOutput = git status --porcelain 2>$null if ($statusOutput) { Write-Host "[INFO] You have uncommitted changes. This is OK, but make sure all required files are committed." -ForegroundColor Yellow } Write-Host "" if ($allChecksPassed) { Write-Host "========================================" -ForegroundColor Green Write-Host " CONGRATULATIONS! Challenge Complete! " -ForegroundColor Green Write-Host "========================================" -ForegroundColor Green Write-Host "" Write-Host "You've mastered the basics of git!" -ForegroundColor Cyan Write-Host "You can now move on to Module 02." -ForegroundColor Cyan Write-Host "" } else { Write-Host "========================================" -ForegroundColor Red Write-Host " Challenge Not Complete - Try Again! " -ForegroundColor Red Write-Host "========================================" -ForegroundColor Red Write-Host "" Write-Host "Review the errors above and try again." -ForegroundColor Yellow Write-Host "Hint: Check 'git log' and 'git status' to see what you've done." -ForegroundColor Yellow Write-Host "" exit 1 }