feat: check for mainbranch

This commit is contained in:
Bjarke Sporring
2026-01-15 14:31:00 +01:00
parent 40341d21a7
commit 9fbdd941fa
8 changed files with 152 additions and 41 deletions

View File

@@ -32,6 +32,9 @@ git init | Out-Null
git config user.name "Workshop Student"
git config user.email "student@example.com"
# Detect the default branch name after first commit (created below)
# Will be detected after the initial commit in SCENARIO 1
# ============================================================================
# SCENARIO 1: Regular Revert (Basic)
# ============================================================================
@@ -53,6 +56,14 @@ Set-Content -Path "calculator.py" -Value $calcContent
git add .
git commit -m "Initial calculator implementation" | Out-Null
# Detect the main branch name after first commit
$mainBranch = git branch --show-current
if (-not $mainBranch) {
$mainBranch = git config --get init.defaultBranch
if (-not $mainBranch) { $mainBranch = "main" }
}
Write-Host "Default branch detected: $mainBranch" -ForegroundColor Yellow
# Create regular-revert branch
git switch -c regular-revert | Out-Null
@@ -136,7 +147,7 @@ Write-Host "[CREATED] regular-revert branch with bad divide commit" -ForegroundC
Write-Host "`nScenario 2: Creating merge-revert scenario..." -ForegroundColor Cyan
# Switch back to main
git switch main | Out-Null
git switch $mainBranch | Out-Null
# Create merge-revert branch
git switch -c merge-revert | Out-Null
@@ -222,7 +233,7 @@ Write-Host "[CREATED] merge-revert branch with merge commit to revert" -Foregrou
Write-Host "`nScenario 3: Creating multi-revert branch..." -ForegroundColor Cyan
# Switch back to main
git switch main | Out-Null
git switch $mainBranch | Out-Null
# Create multi-revert branch
git switch -c multi-revert | Out-Null