1
0
mirror of https://github.com/fleschutz/PowerShell.git synced 2025-03-26 22:36:12 +01:00

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

@ -102,6 +102,7 @@ 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-latest-tags.ps1, lists the latests tags in all Git repositories under the current/given directory
list-memos.ps1, lists the memos at $HOME/Memos.csv
list-unused-files.ps1, lists unused files in a directory tree
list-cmdlets.ps1, lists the PowerShell cmdlets

Can't render this file because it has a wrong number of fields in line 79.

View File

@ -161,6 +161,7 @@ Mega Collection of PowerShell Scripts
* [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-latest-tags.ps1](Scripts/list-latest-tags.ps1) - lists the latests tags in all Git repositories under the current/given directory
* [list-submodules.ps1](Scripts/list-submodules.ps1) - lists the submodules of the current/given Git repository
* [list-tags.ps1](Scripts/list-tags.ps1) - lists all tags in the current/given Git repository
* [make-repo.ps1](Scripts/make-repo.ps1) - builds the current/given Git repository

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
}