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

View File

@ -94,6 +94,7 @@ list-fritzbox-devices.ps1, lists FRITZ!Box's known devices
list-hidden-files.ps1, lists hidden files within the given directory tree
list-installed-apps.ps1, lists the installed Windows Store apps
list-installed-software.ps1, lists the installed software (except Windows Store apps)
list-latest-tag.ps1, lists the latest tag on the current branch in a Git repository
list-logbook.ps1, lists the content of the logbook
list-unused-files.ps1, lists unused files in a directory tree
list-cmdlets.ps1, lists the PowerShell cmdlets

1 Script Description
94 list-hidden-files.ps1 lists hidden files within the given directory tree
95 list-installed-apps.ps1 lists the installed Windows Store apps
96 list-installed-software.ps1 lists the installed software (except Windows Store apps)
97 list-latest-tag.ps1 lists the latest tag on the current branch in a Git repository
98 list-logbook.ps1 lists the content of the logbook
99 list-unused-files.ps1 lists unused files in a directory tree
100 list-cmdlets.ps1 lists the PowerShell cmdlets

View File

@ -146,6 +146,7 @@ Mega Collection of PowerShell Scripts
* [fetch-repos.ps1](Scripts/fetch-repos.ps1) - fetches updates for all Git repositories under the current/given directory (including submodules)
* [list-branches.ps1](Scripts/list-branches.ps1) - lists all branches in the current/given Git repository
* [list-commits.ps1](Scripts/list-commits.ps1) - lists all commits in the current/given Git repository
* [list-latest-tag.ps1](Scripts/list-latest-tag.ps1) - lists the latest tag on the current branch in a Git repository
* [list-tags.ps1](Scripts/list-tags.ps1) - lists all tags in the current/given Git repository
* [pull-repo.ps1](Scripts/pull-repo.ps1) - pulls updates for the current/given Git repository (including submodules)
* [pull-repos.ps1](Scripts/pull-repos.ps1) - pulls updates for all Git repositories under the current/given directory (including submodules)

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
}