diff --git a/util.ps1 b/util.ps1 new file mode 100644 index 0000000..6eadaf8 --- /dev/null +++ b/util.ps1 @@ -0,0 +1,50 @@ +function Write-Pass { + param([string]$Message) + Write-Host "[PASS] $Message" -ForegroundColor Green +} + +function Write-Fail { + param([string]$Message) + Write-Host "[FAIL] $Message" -ForegroundColor Red + $script:allChecksPassed = $false +} + +function Write-Hint { + param([string]$Message) + Write-Host "[HINT] $Message" -ForegroundColor Yellow +} + +function Write-Info { + param([string]$Message) + Write-Host "[INFO] $Message" -ForegroundColor Cyan +} + +function Write-Error { + param([string] $Message) + Write-Host "[ERROR] $Message" -ForegroundColor Red +} + + +function Get-LocalBranches { + return git for-each-ref --format='%(refname:short)' refs/heads +} + +function Get-MainBranch { + $mainBranch = git branch --show-current 2>$null + $allBranches = Get-LocalBranches + 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" } + } + } + + return $mainBranch +}