mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-05-05 08:04:43 +02:00
Update list-repos.ps1
This commit is contained in:
parent
b867ccf44c
commit
82964e0200
@ -24,16 +24,16 @@ param([string]$ParentDir = "$PWD")
|
|||||||
function ListRepos {
|
function ListRepos {
|
||||||
[int]$No = 1
|
[int]$No = 1
|
||||||
$Folders = (Get-ChildItem "$ParentDir" -attributes Directory)
|
$Folders = (Get-ChildItem "$ParentDir" -attributes Directory)
|
||||||
foreach ($Folder in $Folders) {
|
foreach($Folder in $Folders) {
|
||||||
$FolderName = (Get-Item "$Folder").Name
|
$FolderName = (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)
|
$LatestTagCommitID = (git -C "$Folder" rev-list --tags --max-count=1)
|
||||||
$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])"
|
||||||
|
Loading…
Reference in New Issue
Block a user