feat: check for mainbranch
This commit is contained in:
@@ -59,15 +59,39 @@ if (-not (Test-Path ".git")) {
|
||||
|
||||
Write-Host "`n=== Verifying Module 04: Merge Conflicts ===" -ForegroundColor Cyan
|
||||
|
||||
# ============================================================================
|
||||
# Detect the main branch name (could be main, master, etc.)
|
||||
# ============================================================================
|
||||
# Try to get the default branch from remote origin first
|
||||
$mainBranch = git symbolic-ref refs/remotes/origin/HEAD 2>$null | Split-Path -Leaf
|
||||
if (-not $mainBranch) {
|
||||
# Fallback: try to detect from local branches
|
||||
$allBranches = git branch --list 2>$null | ForEach-Object { $_.Trim('* ') }
|
||||
if ($allBranches -contains "main") {
|
||||
$mainBranch = "main"
|
||||
} elseif ($allBranches -contains "master") {
|
||||
$mainBranch = "master"
|
||||
} else {
|
||||
# Get the default branch from git config
|
||||
$mainBranch = git config --get init.defaultBranch
|
||||
if (-not $mainBranch) {
|
||||
# Ultimate fallback: use the first branch
|
||||
$mainBranch = $allBranches | Select-Object -First 1
|
||||
if (-not $mainBranch) { $mainBranch = "main" }
|
||||
}
|
||||
}
|
||||
}
|
||||
Write-Host "Detected main branch: $mainBranch" -ForegroundColor Cyan
|
||||
|
||||
# ============================================================================
|
||||
# Check current branch
|
||||
# ============================================================================
|
||||
$currentBranch = git branch --show-current 2>$null
|
||||
if ($currentBranch -eq "main") {
|
||||
Write-Pass "Currently on main branch"
|
||||
if ($currentBranch -eq $mainBranch) {
|
||||
Write-Pass "Currently on $mainBranch branch"
|
||||
} else {
|
||||
Write-Fail "Should be on main branch (currently on: $currentBranch)"
|
||||
Write-Hint "Switch to main with: git switch main"
|
||||
Write-Fail "Should be on $mainBranch branch (currently on: $currentBranch)"
|
||||
Write-Hint "Switch to $mainBranch with: git switch $mainBranch"
|
||||
}
|
||||
|
||||
# ============================================================================
|
||||
@@ -196,7 +220,7 @@ if ($script:allChecksPassed) {
|
||||
Write-Host "[SUMMARY] Some checks failed. Review the hints above." -ForegroundColor Red
|
||||
Write-Host ""
|
||||
Write-Host "Quick guide:" -ForegroundColor Cyan
|
||||
Write-Host " 1. Make sure you're on main: git switch main" -ForegroundColor White
|
||||
Write-Host " 1. Make sure you're on $mainBranch : git switch $mainBranch" -ForegroundColor White
|
||||
Write-Host " 2. Merge first branch: git merge add-timeout" -ForegroundColor White
|
||||
Write-Host " 3. Merge second branch: git merge add-debug" -ForegroundColor White
|
||||
Write-Host " 4. Resolve conflict: edit config.json, remove markers, keep both settings" -ForegroundColor White
|
||||
|
||||
Reference in New Issue
Block a user