86 lines
2.7 KiB
PowerShell
86 lines
2.7 KiB
PowerShell
#!/usr/bin/env pwsh
|
|
<#
|
|
.SYNOPSIS
|
|
Sets up the Module 03 challenge environment for learning about branches.
|
|
|
|
.DESCRIPTION
|
|
This script creates a challenge directory with a Git repository that
|
|
contains a couple of commits on the main branch. Students will create
|
|
a feature branch and make commits on it.
|
|
#>
|
|
|
|
Write-Host "`n=== Setting up Module 03 Challenge ===" -ForegroundColor Cyan
|
|
|
|
# Remove existing challenge directory if it exists
|
|
if (Test-Path "challenge") {
|
|
Write-Host "Removing existing challenge directory..." -ForegroundColor Yellow
|
|
Remove-Item -Recurse -Force "challenge"
|
|
}
|
|
|
|
# Create fresh challenge directory
|
|
Write-Host "Creating challenge directory..." -ForegroundColor Green
|
|
New-Item -ItemType Directory -Path "challenge" | Out-Null
|
|
Set-Location "challenge"
|
|
|
|
# Initialize Git repository
|
|
Write-Host "Initializing Git repository..." -ForegroundColor Green
|
|
git init | Out-Null
|
|
|
|
# Configure git for this repository
|
|
git config user.name "Workshop Student"
|
|
git config user.email "student@example.com"
|
|
|
|
# Commit 1: Initial commit
|
|
Write-Host "Creating initial project..." -ForegroundColor Green
|
|
$mainContent = @"
|
|
# main.py - Main application file
|
|
|
|
def main():
|
|
print("Welcome to the Application!")
|
|
print("This is the main branch")
|
|
|
|
if __name__ == "__main__":
|
|
main()
|
|
"@
|
|
Set-Content -Path "main.py" -Value $mainContent
|
|
|
|
git add .
|
|
git commit -m "Initial commit" | Out-Null
|
|
|
|
# Commit 2: Add main functionality
|
|
Write-Host "Adding main functionality..." -ForegroundColor Green
|
|
$mainContent = @"
|
|
# main.py - Main application file
|
|
|
|
def main():
|
|
print("Welcome to the Application!")
|
|
print("This is the main branch")
|
|
run_application()
|
|
|
|
def run_application():
|
|
print("Application is running...")
|
|
print("Ready for new features!")
|
|
|
|
if __name__ == "__main__":
|
|
main()
|
|
"@
|
|
Set-Content -Path "main.py" -Value $mainContent
|
|
|
|
git add .
|
|
git commit -m "Add main functionality" | Out-Null
|
|
|
|
# Return to module directory
|
|
Set-Location ..
|
|
|
|
Write-Host "`n=== Setup Complete! ===" -ForegroundColor Green
|
|
Write-Host "`nYour challenge environment is ready in the 'challenge/' directory." -ForegroundColor Cyan
|
|
Write-Host "`nNext steps:" -ForegroundColor Cyan
|
|
Write-Host " 1. cd challenge" -ForegroundColor White
|
|
Write-Host " 2. Create a new branch: git checkout -b feature-login" -ForegroundColor White
|
|
Write-Host " 3. Create login.py and commit it" -ForegroundColor White
|
|
Write-Host " 4. Make another commit on the feature branch" -ForegroundColor White
|
|
Write-Host " 5. Switch back to main: git checkout main" -ForegroundColor White
|
|
Write-Host " 6. Observe that login.py doesn't exist on main!" -ForegroundColor White
|
|
Write-Host " 7. Run '..\verify.ps1' to check your solution" -ForegroundColor White
|
|
Write-Host ""
|