Add list-tags.ps1

This commit is contained in:
Markus Fleschutz 2021-03-18 16:58:41 +01:00
parent 54d9084c0e
commit e29e0c1c14
3 changed files with 37 additions and 0 deletions

View File

@ -73,6 +73,7 @@ list-profiles.ps1, lists your PowerShell profiles
list-random-passwords.ps1, prints a list of random passwords
list-random-pins.ps1, prints a list of random PIN's
list-scripts.ps1, lists all PowerShell scripts in this repository
list-tags.ps1, lists all tags in the current/given Git repository
list-timezones.ps1, lists all time zones available
list-user-groups.ps1, lists the user groups on the local computer
locate-city.ps1, prints the geographic location of the given city

1 Script Description
73 list-random-passwords.ps1 prints a list of random passwords
74 list-random-pins.ps1 prints a list of random PIN's
75 list-scripts.ps1 lists all PowerShell scripts in this repository
76 list-tags.ps1 lists all tags in the current/given Git repository
77 list-timezones.ps1 lists all time zones available
78 list-user-groups.ps1 lists the user groups on the local computer
79 locate-city.ps1 prints the geographic location of the given city

View File

@ -109,6 +109,7 @@ 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-tags.ps1](Scripts/list-tags.ps1) - lists all tags in the current/given Git repository
* [switch-branch.ps1](Scripts/switch-branch.ps1) - switches the branch in the current/given Git repository (including submodules)
* [update-repos.ps1](Scripts/update-repos.ps1) - updates all Git repositories under the current/given directory (including submodules)

35
Scripts/list-tags.ps1 Executable file
View File

@ -0,0 +1,35 @@
#!/bin/powershell
<#
.SYNTAX ./list-tags.ps1 [<repo-dir>]
.DESCRIPTION lists all tags in the current/given Git repository
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
param($RepoDir = "$PWD")
try {
write-output "Fetching updates for Git repository $RepoDir ..."
if (-not(test-path "$RepoDir" -pathType container)) { throw "Can't access directory: $RepoDir" }
set-location "$RepoDir"
& git --version
if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" }
& git fetch --all --recurse-submodules
if ($lastExitCode -ne "0") { throw "'git fetch --all --recurse-submodules' failed" }
write-output ""
write-output "List of Git Tags"
write-output "----------------"
& git tag
if ($lastExitCode -ne "0") { throw "'git tag' failed" }
write-output ""
exit 0
} catch {
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}