mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-04-21 09:28:21 +02:00
Improved list-repos.ps1
This commit is contained in:
parent
4432c09a61
commit
48ef4c3fa1
@ -21,22 +21,22 @@
|
|||||||
param([string]$parentDir = "$PWD")
|
param([string]$parentDir = "$PWD")
|
||||||
|
|
||||||
function ListRepos {
|
function ListRepos {
|
||||||
$folders = (Get-ChildItem "$parentDir" -attributes Directory)
|
$dirs = (Get-ChildItem "$parentDir" -attributes Directory)
|
||||||
foreach($folder in $folders) {
|
foreach($dir in $dirs) {
|
||||||
$folderName = (Get-Item "$folder").Name
|
$dirName = (Get-Item "$dir").Name
|
||||||
$latestTagCommitID = (git -C "$folder" rev-list --tags --max-count=1)
|
$latestTagCommitID = (git -C "$dir" rev-list --tags --max-count=1)
|
||||||
if ($latestTagCommitID -ne "") {
|
if ("$latestTagCommitID" -ne "") {
|
||||||
$latestTag = (git -C "$folder" describe --tags $latestTagCommitID)
|
$latestTag = (git -C "$dir" describe --tags $latestTagCommitID)
|
||||||
} else {
|
} else {
|
||||||
$latestTag = ""
|
$latestTag = ""
|
||||||
}
|
}
|
||||||
$branch = (git -C "$folder" branch --show-current)
|
$branch = (git -C "$dir" branch --show-current)
|
||||||
$remoteURL = (git -C "$folder" remote get-url origin)
|
$remoteURL = (git -C "$dir" remote get-url origin)
|
||||||
$numCommits = (git -C "$folder" rev-list HEAD...origin/$branch --count)
|
$numCommits = (git -C "$dir" rev-list HEAD...origin/$branch --count)
|
||||||
$status = (git -C "$folder" status --short)
|
$status = (git -C "$dir" status --short)
|
||||||
if ("$status" -eq "") { $status = "✔️clean" }
|
if ("$status" -eq "") { $status = "✔️clean" }
|
||||||
elseif ("$status" -like " M *") { $status = "⚠️changed" }
|
elseif ("$status" -like " M *") { $status = "⚠️changed" }
|
||||||
New-Object PSObject -property @{'REPOSITORY'="📂$folderName";'LATEST TAG'="$latestTag";'BRANCH'="$branch";'REMOTE URL'="$remoteURL";'STATUS'="$status ↓$numCommits"}
|
New-Object PSObject -property @{'REPOSITORY'="📂$dirName";'LATEST TAG'="$latestTag";'BRANCH'="$branch";'REMOTE URL'="$remoteURL";'STATUS'="$status ↓$numCommits"}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user