mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-12-15 19:21:04 +01:00
Update list-repos.ps1
This commit is contained in:
parent
bbbd454592
commit
fd667a087b
@ -8,10 +8,10 @@
|
||||
.EXAMPLE
|
||||
PS> ./list-repos C:\MyRepos
|
||||
|
||||
Repository Branch Latest Tag Updates Status
|
||||
---------- ------ ---------- ------- ------
|
||||
📂cmake 🌵main v3.23.0 ↓0 ✔️clean
|
||||
📂opencv 🌵main 4.5.5 ↓0 ⚠️modified
|
||||
Repository Latest Tag Branch Updates Status
|
||||
---------- ---------- ------ ------- ------
|
||||
📂cmake v3.23.0 🌵main ↓0 ✔️clean
|
||||
📂opencv 4.5.5 🌵main ↓0 ⚠️modified
|
||||
...
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
@ -25,18 +25,18 @@ function ListRepos {
|
||||
$Folders = (Get-ChildItem "$ParentDir" -attributes Directory)
|
||||
foreach($Folder in $Folders) {
|
||||
$Repository = (Get-Item "$Folder").Name
|
||||
$Branch = (git -C "$Folder" branch --show-current)
|
||||
$LatestTagCommitID = (git -C "$Folder" rev-list --tags --max-count=1)
|
||||
if ($LatestTagCommitID -ne "") {
|
||||
$LatestTag = (git -C "$Folder" describe --tags $LatestTagCommitID)
|
||||
} else {
|
||||
$LatestTag = ""
|
||||
}
|
||||
$Branch = (git -C "$Folder" branch --show-current)
|
||||
$NumCommits = (git -C "$Folder" rev-list HEAD...origin/$Branch --count)
|
||||
$Status = (git -C "$Folder" status --short)
|
||||
if ("$Status" -eq "") { $Status = "✔️clean" }
|
||||
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";'Latest Tag'="$LatestTag";'Branch'="🌵$Branch";'Updates'="↓$NumCommits";'Status'="$Status";}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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=22},@{e='Branch';width=20},'Latest Tag',@{e='Updates';width=10},Status
|
||||
ListRepos | Format-Table -property @{e='Repository';width=20},@{e='Latest Tag';width=18},@{e='Branch';width=14},@{e='Updates';width=8},Status
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
Loading…
Reference in New Issue
Block a user