Skip to content
Snippets Groups Projects
Commit 664ab811 authored by Niko Ehrenfeuchter's avatar Niko Ehrenfeuchter :keyboard:
Browse files

Make error handling in Prepare-Build more robust.

parent 50d9ab06
No related branches found
No related tags found
No related merge requests found
......@@ -3,24 +3,30 @@ Param(
[Parameter(Mandatory=$True)][string] $ProjectDir
)
$ErrorActionPreference = "Stop"
$oldpwd = pwd
cd $ProjectDir -ErrorAction Stop
try {
$CommitName = git describe --tags
$GitStatus = git status --porcelain
$CommitName = & git describe --tags
if (-Not $?) { throw }
$GitStatus = & git status --porcelain
if (-Not $?) { throw }
if ($GitStatus.Length -gt 0) {
Write-Output "NOTE: repository has uncommitted changes!"
$CommitName = "$($CommitName)-unclean"
}
}
catch {
$CommitName = "commit unknown"
$GitStatus = "status unknown"
Write-Output "$(">"*8) Running git failed, using default values! $("<"*8)"
}
if ($GitStatus.Length -gt 0) {
Write-Output "NOTE: repository has uncommitted changes!"
$CommitName = "$($CommitName)-unclean"
}
$Date = Get-Date -Format 'yyyy-MM-dd HH:mm:ss'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment