Add list-latest-tags.ps1

This commit is contained in:
Markus Fleschutz
2021-08-10 21:36:56 +02:00
parent ec6730c09b
commit efe8a7db6e
4 changed files with 45 additions and 2 deletions

View File

@ -23,8 +23,8 @@ try {
$RepoDirName = (get-item "$RepoDir").Name
"🢃 Fetching updates for 📂$RepoDirName ..."
& git -C "$RepoDir" fetch
if ($lastExitCode -ne "0") { throw "'git fetch' failed" }
& git -C "$RepoDir" fetch --tags
if ($lastExitCode -ne "0") { throw "'git fetch --tags' failed" }
$Tag = (git -C "$RepoDir" describe --tags --abbrev=0)
"🔖$Tag"

41
Scripts/list-latest-tags.ps1 Executable file
View File

@ -0,0 +1,41 @@
<#
.SYNOPSIS
list-latest-tags.ps1 [<parent-dir>]
.DESCRIPTION
Lists the latests tags in all Git repositories under the current/given directory
.EXAMPLE
PS> .\list-latest-tags.ps1 C:\MyRepos
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz
License: CC0
#>
param([string]$ParentDir = "$PWD")
try {
if (-not(test-path "$ParentDir" -pathType container)) { throw "Can't access directory: $ParentDir" }
$Null = (git --version)
if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" }
$Folders = (get-childItem "$ParentDir" -attributes Directory)
$FolderCount = $Folders.Count
$ParentDirName = (get-item "$ParentDir").Name
"Found $FolderCount subfolders in 📂$ParentDirName..."
foreach ($Folder in $Folders) {
$FolderName = (get-item "$Folder").Name
& git -C "$Folder" fetch --tags
if ($lastExitCode -ne "0") { throw "'git fetch --tags' failed" }
$LatestTag = (git -C "$Folder" describe --tags --abbrev=0)
"* $FolderName $LatestTag"
}
exit 0
} catch {
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}