Update list-repos.ps1

This commit is contained in:
Markus Fleschutz 2023-11-04 10:20:47 +01:00
parent 4833ecbfa4
commit c5eea816ee

View File

@ -8,8 +8,8 @@
.EXAMPLE
PS> ./list-repos C:\MyRepos
Repository Latest Tag Branch Status Remote
---------- ---------- ------ ------ ------
Local Repo Latest Tag Branch Status Remote URL
---------- ---------- ------ ------ ----------
📂cmake v3.23.0 main clean git@github.com:Kitware/CMake 0
...
.LINK
@ -23,7 +23,7 @@ param([string]$ParentDir = "$PWD")
function ListRepos {
$Folders = (Get-ChildItem "$ParentDir" -attributes Directory)
foreach($Folder in $Folders) {
$Repository = (Get-Item "$Folder").Name
$FolderName = (Get-Item "$Folder").Name
$LatestTagCommitID = (git -C "$Folder" rev-list --tags --max-count=1)
if ($LatestTagCommitID -ne "") {
$LatestTag = (git -C "$Folder" describe --tags $LatestTagCommitID)
@ -36,7 +36,7 @@ function ListRepos {
$Status = (git -C "$Folder" status --short)
if ("$Status" -eq "") { $Status = "clean" }
elseif ("$Status" -like " M *") { $Status = "modified" }
New-Object PSObject -property @{'Repository'="📂$Repository";'Latest Tag'="$LatestTag";'Branch'="$Branch";'Status'="$Status";'Remote'="$RemoteURL$NumCommits";}
New-Object PSObject -property @{'Local Repo'="📂$FolderName";'Latest Tag'="$LatestTag";'Branch'="$Branch";'Status'="$Status";'Remote URL'="$RemoteURL$NumCommits";}
}
}
@ -46,7 +46,7 @@ try {
$Null = (git --version)
if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" }
ListRepos | Format-Table -property @{e='Repository';width=20},@{e='Latest Tag';width=18},@{e='Branch';width=20},@{e='Status';width=10},Remote
ListRepos | Format-Table -property @{e='Local Repo';width=19},@{e='Latest Tag';width=18},@{e='Branch';width=20},@{e='Status';width=10},'Remote URL'
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"