Files
git-workshop/util.ps1
2026-01-21 11:40:00 +01:00

45 lines
999 B
PowerShell

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 {
$mainBranch = git config --get init.defaultBranch
}
return $mainBranch
}