29 lines
679 B
PowerShell
29 lines
679 B
PowerShell
function Find-GitExecutablePath {
|
|
<#
|
|
.SYNOPSIS
|
|
Find the git executable path on this system
|
|
#>
|
|
param ()
|
|
|
|
$logLead = (Get-LogLeadName)
|
|
|
|
$path = (Get-Command git).Source
|
|
|
|
$isMissing = [string]::IsNullOrWhiteSpace($path)
|
|
|
|
$defaultPaths = @('C:\Program Files\git\bin\git.exe','C:\Program Files (x86)\git\bin\git.exe')
|
|
|
|
if (!$isMissing) {
|
|
return $path
|
|
}
|
|
|
|
foreach ($defaultPath in $defaultPaths) {
|
|
$path = $defaultPath
|
|
if (Test-Path -Path $path) {
|
|
return $path
|
|
}
|
|
}
|
|
|
|
# We didn't hit a return statement, therefore this is missing
|
|
throw "$logLead : Can not find an installed/in-path git command"
|
|
} |