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
Branches
No related tags found
No related merge requests found
...@@ -3,24 +3,30 @@ Param( ...@@ -3,24 +3,30 @@ Param(
[Parameter(Mandatory=$True)][string] $ProjectDir [Parameter(Mandatory=$True)][string] $ProjectDir
) )
$ErrorActionPreference = "Stop"
$oldpwd = pwd $oldpwd = pwd
cd $ProjectDir -ErrorAction Stop cd $ProjectDir -ErrorAction Stop
try { try {
$CommitName = git describe --tags $CommitName = & git describe --tags
$GitStatus = git status --porcelain 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 { catch {
$CommitName = "commit unknown" $CommitName = "commit unknown"
$GitStatus = "status 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' $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.
Please register or to comment