Add list-latest-tag.ps1

This commit is contained in:
Markus Fleschutz
2021-04-28 13:01:05 +02:00
parent cfaa7b48da
commit 478d62aa89
3 changed files with 30 additions and 0 deletions

28
Scripts/list-latest-tag.ps1 Executable file
View File

@ -0,0 +1,28 @@
<#
.SYNTAX list-latest-tag.ps1 [<repo-dir>]
.DESCRIPTION lists the latest tag on the current branch in a Git repository
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
param($RepoDir = "$PWD")
try {
if (-not(test-path "$RepoDir" -pathType container)) { throw "Can't access directory: $RepoDir" }
set-location "$RepoDir"
$RepoDirName = (get-item "$RepoDir").Name
"⏳ Fetching updates for Git repository 📂$RepoDirName ..."
$Null = (git --version)
if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" }
& git fetch --all --recurse-submodules --jobs=4
if ($lastExitCode -ne "0") { throw "'git fetch' failed" }
& git describe --tags --abbrev=0
exit 0
} catch {
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}