Update list-repos.ps1

This commit is contained in:
Markus Fleschutz 2023-06-19 12:56:24 +02:00
parent b867ccf44c
commit 82964e0200

View File

@ -31,9 +31,9 @@ function ListRepos {
$LatestTag = (git -C "$Folder" describe --tags $LatestTagCommitID) $LatestTag = (git -C "$Folder" describe --tags $LatestTagCommitID)
$Status = (git -C "$Folder" status --short) $Status = (git -C "$Folder" status --short)
if ("$Status" -eq "") { $Status = "clean" } if ("$Status" -eq "") { $Status = "clean" }
if ("$Status" -like " M *") { $Status = "modified" } elseif ("$Status" -like " M *") { $Status = "MODIFIED" }
$NumCommits = (git -C "$Folder" rev-list HEAD...origin/$Branch --count)
New-Object PSObject -property @{ 'No'="$No"; 'Repository'="$FolderName"; 'Branch'="$Branch"; 'LatestTag'="$LatestTag"; 'Status'="$Status"; } New-Object PSObject -property @{ 'No'="$No"; 'Repository'="$FolderName"; 'Branch'="$Branch"; 'Latest_Tag'="$LatestTag"; 'Status'="$Status$NumCommits"; }
$No++ $No++
} }
} }
@ -44,7 +44,7 @@ try {
$Null = (git --version) $Null = (git --version)
if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" } if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" }
ListRepos | Format-Table -property @{e='No';width=3},@{e='Repository';width=25},@{e='Branch';width=20},LatestTag,Status ListRepos | Format-Table -property @{e='No';width=3},@{e='Repository';width=22},@{e='Branch';width=20},Latest_Tag,Status
exit 0 # success exit 0 # success
} catch { } catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"