2018-03-17 00:36:27 +01:00
|
|
|
|
Set-StrictMode -Version 2.0
|
|
|
|
|
$ErrorActionPreference="Stop"
|
|
|
|
|
|
|
|
|
|
git update-index -q --refresh
|
|
|
|
|
git diff-files --quiet | Out-Null
|
|
|
|
|
|
|
|
|
|
$dirtyTag=""
|
|
|
|
|
if ($LASTEXITCODE -ne 0) {
|
|
|
|
|
$dirtyTag = "-dirty"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
2018-04-11 20:33:53 +02:00
|
|
|
|
git describe --tags --exact-match >$null 2>$null
|
2018-03-17 00:36:27 +01:00
|
|
|
|
# If we get here the above did not throw, so we can use the exact tag
|
2018-04-11 20:33:53 +02:00
|
|
|
|
Write-Output "$(git describe --tags --exact-match)$dirtyTag"
|
2018-03-17 00:36:27 +01:00
|
|
|
|
} catch {
|
|
|
|
|
# Otherwise, append the timestamp of the commit and the hash
|
2018-04-11 20:33:53 +02:00
|
|
|
|
Write-Output "$(git describe --tags --abbrev=0)-$(git show -s --format='%ct-g%h')$dirtyTag"
|
|
|
|
|
}
|
|
|
|
|
|