Don't use a broken version string when git is not found

This commit is contained in:
abcdefg30
2017-05-26 10:31:30 +02:00
committed by reaperrr
parent 057c201e85
commit 841798a0a8

View File

@@ -61,10 +61,18 @@ function Version-Command
}
elseif (Get-Command 'git' -ErrorAction SilentlyContinue)
{
$version = git name-rev --name-only --tags --no-undefined HEAD 2>$null
if ($version -eq $null)
$gitRepo = git rev-parse --is-inside-work-tree
if ($gitRepo)
{
$version = "git-" + (git rev-parse --short HEAD)
$version = git name-rev --name-only --tags --no-undefined HEAD 2>$null
if ($version -eq $null)
{
$version = "git-" + (git rev-parse --short HEAD)
}
}
else
{
echo "Not a git repository. The version will remain unchanged."
}
}
else