refactor: split out merge strategies from essentials
This commit is contained in:
@@ -8,9 +8,9 @@
|
||||
- The challenge directory exists
|
||||
- A Git repository exists
|
||||
- Currently on main branch
|
||||
- feature-api has been merged into main
|
||||
- feature-ui branch exists and has been merged
|
||||
- A merge commit exists (from three-way merge)
|
||||
- feature-login has been merged into main
|
||||
- A merge commit exists (three-way merge)
|
||||
- Login functionality is present on main
|
||||
#>
|
||||
|
||||
Write-Host "`n=== Verifying Module 04 Solution ===" -ForegroundColor Cyan
|
||||
@@ -38,82 +38,63 @@ 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
|
||||
Write-Host "[HINT] Switch to main with: git switch main" -ForegroundColor Yellow
|
||||
$allChecksPassed = $false
|
||||
}
|
||||
|
||||
# Check if feature-api branch exists
|
||||
$featureApiBranch = git branch --list "feature-api" 2>$null
|
||||
if ($featureApiBranch) {
|
||||
Write-Host "[PASS] Branch 'feature-api' exists" -ForegroundColor Green
|
||||
# Check if feature-login branch exists
|
||||
$featureLoginBranch = git branch --list "feature-login" 2>$null
|
||||
if ($featureLoginBranch) {
|
||||
Write-Host "[PASS] Branch 'feature-login' exists" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "[INFO] Branch 'feature-api' not found (may have been deleted after merge)" -ForegroundColor Cyan
|
||||
Write-Host "[INFO] Branch 'feature-login' not found (may have been deleted after merge)" -ForegroundColor Cyan
|
||||
}
|
||||
|
||||
# Check if commits from feature-api are in main
|
||||
$apiRoutesCommit = git log --all --grep="Add API routes" --oneline 2>$null
|
||||
$healthCheckCommit = git log --all --grep="Add health check route" --oneline 2>$null
|
||||
# Check if login.py exists (should be on main after merge)
|
||||
if (Test-Path "login.py") {
|
||||
Write-Host "[PASS] File 'login.py' exists on main (from feature-login merge)" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "[FAIL] File 'login.py' not found on main" -ForegroundColor Red
|
||||
Write-Host "[HINT] This file should appear after merging feature-login into main" -ForegroundColor Yellow
|
||||
$allChecksPassed = $false
|
||||
}
|
||||
|
||||
if ($apiRoutesCommit -and $healthCheckCommit) {
|
||||
# Check if these commits are in main's history
|
||||
$apiRoutesInMain = git log --grep="Add API routes" --oneline 2>$null
|
||||
$healthCheckInMain = git log --grep="Add health check route" --oneline 2>$null
|
||||
|
||||
if ($apiRoutesInMain -and $healthCheckInMain) {
|
||||
Write-Host "[PASS] Commits from feature-api are merged into main" -ForegroundColor Green
|
||||
# Check if app.py contains login integration
|
||||
if (Test-Path "app.py") {
|
||||
$appContent = Get-Content "app.py" -Raw
|
||||
if ($appContent -match "login") {
|
||||
Write-Host "[PASS] app.py contains login integration" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "[FAIL] Commits from feature-api not found in main" -ForegroundColor Red
|
||||
Write-Host "[HINT] Merge feature-api with: git merge feature-api" -ForegroundColor Yellow
|
||||
Write-Host "[FAIL] app.py doesn't contain login integration" -ForegroundColor Red
|
||||
Write-Host "[HINT] After merging, app.py should import and use the login module" -ForegroundColor Yellow
|
||||
$allChecksPassed = $false
|
||||
}
|
||||
} else {
|
||||
Write-Host "[FAIL] Expected commits from feature-api not found" -ForegroundColor Red
|
||||
Write-Host "[HINT] Did you run setup.ps1?" -ForegroundColor Yellow
|
||||
Write-Host "[FAIL] app.py not found" -ForegroundColor Red
|
||||
$allChecksPassed = $false
|
||||
}
|
||||
|
||||
# Check if api-routes.py exists (should be on main after merge)
|
||||
if (Test-Path "api-routes.py") {
|
||||
Write-Host "[PASS] File 'api-routes.py' exists on main (from feature-api merge)" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "[FAIL] File 'api-routes.py' not found on main" -ForegroundColor Red
|
||||
Write-Host "[HINT] This file should appear after merging feature-api" -ForegroundColor Yellow
|
||||
$allChecksPassed = $false
|
||||
}
|
||||
|
||||
# Check if feature-ui branch exists
|
||||
$featureUiBranch = git branch --list "feature-ui" 2>$null
|
||||
if ($featureUiBranch) {
|
||||
Write-Host "[PASS] Branch 'feature-ui' exists" -ForegroundColor Green
|
||||
|
||||
# Check if feature-ui has commits
|
||||
$uiCommitCount = git rev-list main..feature-ui --count 2>$null
|
||||
if ($uiCommitCount -gt 0) {
|
||||
Write-Host "[INFO] Branch 'feature-ui' has $uiCommitCount commit(s)" -ForegroundColor Cyan
|
||||
}
|
||||
} else {
|
||||
Write-Host "[FAIL] Branch 'feature-ui' not found" -ForegroundColor Red
|
||||
Write-Host "[HINT] Create feature-ui with: git checkout -b feature-ui" -ForegroundColor Yellow
|
||||
$allChecksPassed = $false
|
||||
}
|
||||
|
||||
# Check for merge commits (indicates three-way merge happened)
|
||||
# Check for merge commit (indicates three-way merge happened)
|
||||
$mergeCommits = git log --merges --oneline 2>$null
|
||||
if ($mergeCommits) {
|
||||
Write-Host "[PASS] Merge commit(s) found (three-way merge completed)" -ForegroundColor Green
|
||||
Write-Host "[PASS] Merge commit found (three-way merge completed)" -ForegroundColor Green
|
||||
|
||||
# Get the merge commit message
|
||||
$mergeMessage = git log --merges --format=%s -1 2>$null
|
||||
Write-Host "[INFO] Merge commit message: '$mergeMessage'" -ForegroundColor Cyan
|
||||
} else {
|
||||
Write-Host "[FAIL] No merge commits found" -ForegroundColor Red
|
||||
Write-Host "[HINT] Create divergence: make commits on both main and feature-ui, then merge" -ForegroundColor Yellow
|
||||
Write-Host "[FAIL] No merge commit found" -ForegroundColor Red
|
||||
Write-Host "[HINT] Merge feature-login into main with: git merge feature-login" -ForegroundColor Yellow
|
||||
$allChecksPassed = $false
|
||||
}
|
||||
|
||||
# Check if ui.py exists (should be on main after merge)
|
||||
if (Test-Path "ui.py") {
|
||||
Write-Host "[PASS] File 'ui.py' exists on main (from feature-ui merge)" -ForegroundColor Green
|
||||
# Check if both branches contributed commits (true three-way merge)
|
||||
$totalCommits = git rev-list --count HEAD 2>$null
|
||||
if ($totalCommits -ge 4) {
|
||||
Write-Host "[PASS] Repository has $totalCommits commits (branches diverged properly)" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "[FAIL] File 'ui.py' not found on main" -ForegroundColor Red
|
||||
Write-Host "[HINT] Create ui.py on feature-ui branch and merge it into main" -ForegroundColor Yellow
|
||||
$allChecksPassed = $false
|
||||
Write-Host "[WARN] Repository has only $totalCommits commits (expected at least 4)" -ForegroundColor Yellow
|
||||
Write-Host "[INFO] This might still be correct if you deleted commits" -ForegroundColor Cyan
|
||||
}
|
||||
|
||||
Set-Location ..
|
||||
@@ -124,13 +105,14 @@ if ($allChecksPassed) {
|
||||
Write-Host "=====================================" -ForegroundColor Green
|
||||
Write-Host " CONGRATULATIONS! CHALLENGE PASSED!" -ForegroundColor Green
|
||||
Write-Host "=====================================" -ForegroundColor Green
|
||||
Write-Host "`nYou've successfully learned about Git merging!" -ForegroundColor Cyan
|
||||
Write-Host "`nYou've successfully completed your first branch merge!" -ForegroundColor Cyan
|
||||
Write-Host "You now understand:" -ForegroundColor Cyan
|
||||
Write-Host " - Fast-forward merges (when main hasn't changed)" -ForegroundColor White
|
||||
Write-Host " - Three-way merges (when branches have diverged)" -ForegroundColor White
|
||||
Write-Host " - How to use git merge to combine branches" -ForegroundColor White
|
||||
Write-Host " - Merge commits and how to view them" -ForegroundColor White
|
||||
Write-Host "`nReady for the next module!" -ForegroundColor Green
|
||||
Write-Host " - How to merge branches with git merge" -ForegroundColor White
|
||||
Write-Host " - What a merge commit is and why it's created" -ForegroundColor White
|
||||
Write-Host " - How divergent branches are combined" -ForegroundColor White
|
||||
Write-Host " - How to visualize merges with git log --graph" -ForegroundColor White
|
||||
Write-Host "`nNext up: Module 05 - Merge Conflicts!" -ForegroundColor Yellow
|
||||
Write-Host "You'll learn what happens when Git can't automatically merge." -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
} else {
|
||||
Write-Host "`n[SUMMARY] Some checks failed. Review the hints above and try again." -ForegroundColor Red
|
||||
|
||||
Reference in New Issue
Block a user