98 lines
2.8 KiB
PowerShell
98 lines
2.8 KiB
PowerShell
#!/usr/bin/env pwsh
|
|
|
|
<#
|
|
.SYNOPSIS
|
|
Sets up the merge conflicts challenge environment.
|
|
|
|
.DESCRIPTION
|
|
Creates a Git repository with a merge conflict scenario involving
|
|
a configuration file that has been modified differently on two branches.
|
|
#>
|
|
|
|
# Remove existing challenge directory if present
|
|
if (Test-Path "challenge") {
|
|
Write-Host "Removing existing challenge directory..." -ForegroundColor Yellow
|
|
Remove-Item -Path "challenge" -Recurse -Force
|
|
}
|
|
|
|
# Create challenge directory
|
|
Write-Host "Creating challenge environment..." -ForegroundColor Cyan
|
|
New-Item -ItemType Directory -Path "challenge" | Out-Null
|
|
Set-Location "challenge"
|
|
|
|
# Initialize git repository
|
|
git init | Out-Null
|
|
git config user.name "Workshop User" | Out-Null
|
|
git config user.email "user@workshop.local" | Out-Null
|
|
|
|
# Create initial config.json file
|
|
$initialConfig = @"
|
|
{
|
|
"app": {
|
|
"name": "MyApp",
|
|
"version": "1.0.0",
|
|
"port": 3000
|
|
}
|
|
}
|
|
"@
|
|
|
|
Set-Content -Path "config.json" -Value $initialConfig
|
|
git add config.json
|
|
git commit -m "Initial configuration" | Out-Null
|
|
|
|
# Create feature branch
|
|
git branch update-config | Out-Null
|
|
|
|
# On main branch: Add timeout setting
|
|
$mainConfig = @"
|
|
{
|
|
"app": {
|
|
"name": "MyApp",
|
|
"version": "1.0.0",
|
|
"port": 3000,
|
|
"timeout": 5000
|
|
}
|
|
}
|
|
"@
|
|
|
|
Set-Content -Path "config.json" -Value $mainConfig
|
|
git add config.json
|
|
git commit -m "Add timeout configuration" | Out-Null
|
|
|
|
# Switch to feature branch: Add debug setting (conflicting change)
|
|
git switch update-config | Out-Null
|
|
|
|
$featureConfig = @"
|
|
{
|
|
"app": {
|
|
"name": "MyApp",
|
|
"version": "1.0.0",
|
|
"port": 3000,
|
|
"debug": true
|
|
}
|
|
}
|
|
"@
|
|
|
|
Set-Content -Path "config.json" -Value $featureConfig
|
|
git add config.json
|
|
git commit -m "Add debug mode configuration" | Out-Null
|
|
|
|
# Switch back to main branch
|
|
git switch main | Out-Null
|
|
|
|
# Return to module directory
|
|
Set-Location ..
|
|
|
|
Write-Host "`n========================================" -ForegroundColor Green
|
|
Write-Host "Challenge environment created!" -ForegroundColor Green
|
|
Write-Host "========================================" -ForegroundColor Green
|
|
Write-Host "`nYou are now on the 'main' branch." -ForegroundColor Cyan
|
|
Write-Host "There is a branch called 'update-config' with conflicting changes." -ForegroundColor Cyan
|
|
Write-Host "`nYour task:" -ForegroundColor Yellow
|
|
Write-Host "1. Navigate to the challenge directory: cd challenge" -ForegroundColor White
|
|
Write-Host "2. Try to merge the 'update-config' branch into 'main'" -ForegroundColor White
|
|
Write-Host "3. Resolve the merge conflict in config.json" -ForegroundColor White
|
|
Write-Host "4. Keep BOTH the timeout setting AND the debug setting" -ForegroundColor White
|
|
Write-Host "5. Complete the merge" -ForegroundColor White
|
|
Write-Host "`nRun '../verify.ps1' from the challenge directory to check your solution.`n" -ForegroundColor Cyan
|