From 841798a0a8958c8e9e3b8922b0d839a55eafc782 Mon Sep 17 00:00:00 2001 From: abcdefg30 Date: Fri, 26 May 2017 10:31:30 +0200 Subject: [PATCH] Don't use a broken version string when git is not found --- make.ps1 | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/make.ps1 b/make.ps1 index 03da91f9e0..d783ed9444 100644 --- a/make.ps1 +++ b/make.ps1 @@ -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