Update list-repos.ps1

This commit is contained in:
Markus Fleschutz 2023-07-30 18:47:46 +02:00
parent 3c74ae4704
commit 7bfe9fb4da

View File

@ -8,10 +8,10 @@
.EXAMPLE .EXAMPLE
PS> ./list-repos C:\MyRepos PS> ./list-repos C:\MyRepos
Repository Branch LatestTag Status Repository Branch Latest Tag Updates Status
---------- ------ --------- ------ ---------- ------ ---------- ------- ------
cmake main v3.23.0 clean 📂cmake 🌵main v3.23.0 0 clean
opencv main 4.5.5 modified 📂opencv 🌵main 4.5.5 0 modified
... ...
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
@ -26,13 +26,17 @@ function ListRepos {
foreach($Folder in $Folders) { foreach($Folder in $Folders) {
$Repository = (Get-Item "$Folder").Name $Repository = (Get-Item "$Folder").Name
$Branch = (git -C "$Folder" branch --show-current) $Branch = (git -C "$Folder" branch --show-current)
$LatestTagCommitID = (git -C "$Folder" rev-list --tags --max-count=1) | out-null $LatestTagCommitID = (git -C "$Folder" rev-list --tags --max-count=1)
$LatestTag = (git -C "$Folder" describe --tags $LatestTagCommitID) if ($LatestTagCommitID -ne "") {
$LatestTag = (git -C "$Folder" describe --tags $LatestTagCommitID)
} else {
$LatestTag = ""
}
$NumCommits = (git -C "$Folder" rev-list HEAD...origin/$Branch --count) $NumCommits = (git -C "$Folder" rev-list HEAD...origin/$Branch --count)
$Status = (git -C "$Folder" status --short) $Status = (git -C "$Folder" status --short)
if ("$Status" -eq "") { $Status = "clean" } if ("$Status" -eq "") { $Status = "✔️clean" }
elseif ("$Status" -like " M *") { $Status = "MODIFIED" } elseif ("$Status" -like " M *") { $Status = "modified" }
New-Object PSObject -property @{ 'Repository'="📂$Repository"; 'Branch'="$Branch"; 'Latest Tag'="$LatestTag"; 'Updates'="$NumCommits"; 'Status'="$Status"; } New-Object PSObject -property @{ 'Repository'="📂$Repository"; 'Branch'="🌵$Branch"; 'Latest Tag'="$LatestTag"; 'Updates'="$NumCommits"; 'Status'="$Status"; }
} }
} }