Get-ValueOrGitOrDefault.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
$ErrorActionPreference = "Stop" function Get-ValueOrGitOrDefault { Param( [String]$Value, [String]$GitConfigKey, [String]$Default, [String]$GitCommand = "git" ) if ([string]::IsNullOrWhitespace($Value)) { if (-not (Get-Command $GitCommand -ErrorAction SilentlyContinue) -or [string]::IsNullOrWhitespace(($Value = (& $GitCommand config $GitConfigKey)))) { $Value = $Default } } return $Value } |