feat: check for mainbranch
This commit is contained in:
@@ -30,6 +30,19 @@ git init | Out-Null
|
||||
git config user.name "Workshop Student"
|
||||
git config user.email "student@example.com"
|
||||
|
||||
# Detect the default branch name (could be main, master, etc.)
|
||||
# First commit creates the branch, so we detect it after that
|
||||
$mainBranch = git branch --show-current
|
||||
if (-not $mainBranch) {
|
||||
# Fallback: Get default branch name from git config
|
||||
$mainBranch = git config --get init.defaultBranch
|
||||
if (-not $mainBranch) {
|
||||
# Ultimate fallback: use "main"
|
||||
$mainBranch = "main"
|
||||
}
|
||||
}
|
||||
Write-Host "Default branch detected: $mainBranch" -ForegroundColor Yellow
|
||||
|
||||
# ============================================================================
|
||||
# Create base project
|
||||
# ============================================================================
|
||||
@@ -87,7 +100,7 @@ git commit -m "Add timeout configuration" | Out-Null
|
||||
# Branch 2: add-debug (adds debug setting - CONFLICTS with timeout!)
|
||||
# ============================================================================
|
||||
Write-Host "Creating add-debug branch..." -ForegroundColor Cyan
|
||||
git switch main | Out-Null
|
||||
git switch $mainBranch | Out-Null
|
||||
git switch -c add-debug | Out-Null
|
||||
|
||||
$debugConfig = @"
|
||||
@@ -104,8 +117,8 @@ Set-Content -Path "config.json" -Value $debugConfig
|
||||
git add .
|
||||
git commit -m "Add debug mode configuration" | Out-Null
|
||||
|
||||
# Switch back to main
|
||||
git switch main | Out-Null
|
||||
# Switch back to main branch
|
||||
git switch $mainBranch | Out-Null
|
||||
|
||||
# Return to module directory
|
||||
Set-Location ..
|
||||
@@ -113,7 +126,7 @@ Set-Location ..
|
||||
Write-Host "`n=== Setup Complete! ===" -ForegroundColor Green
|
||||
Write-Host "`nYour challenge environment is ready in the 'challenge/' directory." -ForegroundColor Cyan
|
||||
Write-Host "`nThe repository contains:" -ForegroundColor Yellow
|
||||
Write-Host " - main branch: base configuration" -ForegroundColor White
|
||||
Write-Host " - $mainBranch branch: base configuration" -ForegroundColor White
|
||||
Write-Host " - add-timeout branch: adds timeout setting" -ForegroundColor White
|
||||
Write-Host " - add-debug branch: adds debug setting" -ForegroundColor White
|
||||
Write-Host "`nBoth branches modify the same part of config.json!" -ForegroundColor Red
|
||||
|
||||
Reference in New Issue
Block a user