mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-03-31 19:26:27 +02:00
Updated list-repos.ps1
This commit is contained in:
parent
725bdcb680
commit
c3ad18eba7
@ -2,7 +2,7 @@
|
||||
.SYNOPSIS
|
||||
Lists Git repositories
|
||||
.DESCRIPTION
|
||||
This PowerShell script lists all Git repositories in a folder with details such as tag/branch/status/URL.
|
||||
This PowerShell script lists all Git repositories in a folder with details such as latest tag/branch/status/URL.
|
||||
.PARAMETER parentDir
|
||||
Specifies the path to the parent directory (current working directory by default)
|
||||
.EXAMPLE
|
||||
@ -10,7 +10,7 @@
|
||||
|
||||
Local Repo Latest Tag Branch Status Remote Repo
|
||||
---------- ---------- ------ ------ -----------
|
||||
📂cmake v3.23.0 main ✔️clean git@github.com:Kitware/CMake ↓0
|
||||
📂cmake v3.23.0 main ✔️clean ↓0 git@github.com:Kitware/CMake
|
||||
...
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
@ -35,8 +35,8 @@ function ListRepos {
|
||||
$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 @{'Local Repo'="📂$folderName";'Latest Tag'="$latestTag";'Branch'="$branch";'Remote Repo'="$remoteURL";'Status'="$status ↓$numCommits"}
|
||||
elseif ("$status" -like " M *") { $status = "⚠️changed" }
|
||||
New-Object PSObject -property @{'Local Repo'="📂$folderName";'Latest Tag'="$latestTag";'Branch'="$branch";'Status'="$status";'Remote Repo'="↓$numCommits $remoteURL"}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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='Local Repo';width=19},@{e='Latest Tag';width=18},@{e='Branch';width=15},'Remote Repo',@{e='Status';width=14}
|
||||
ListRepos | Format-Table -property @{e='Local Repo';width=19},@{e='Latest Tag';width=16},@{e='Branch';width=19},@{e='Status';width=10},'Remote Repo'
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
Loading…
Reference in New Issue
Block a user