mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-12-26 00:28:53 +01:00
Update list-repos.ps1
This commit is contained in:
parent
4833ecbfa4
commit
c5eea816ee
@ -8,8 +8,8 @@
|
|||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./list-repos C:\MyRepos
|
PS> ./list-repos C:\MyRepos
|
||||||
|
|
||||||
Repository Latest Tag Branch Status Remote
|
Local Repo Latest Tag Branch Status Remote URL
|
||||||
---------- ---------- ------ ------ ------
|
---------- ---------- ------ ------ ----------
|
||||||
📂cmake v3.23.0 main ✔️clean git@github.com:Kitware/CMake ↓0
|
📂cmake v3.23.0 main ✔️clean git@github.com:Kitware/CMake ↓0
|
||||||
...
|
...
|
||||||
.LINK
|
.LINK
|
||||||
@ -23,7 +23,7 @@ param([string]$ParentDir = "$PWD")
|
|||||||
function ListRepos {
|
function ListRepos {
|
||||||
$Folders = (Get-ChildItem "$ParentDir" -attributes Directory)
|
$Folders = (Get-ChildItem "$ParentDir" -attributes Directory)
|
||||||
foreach($Folder in $Folders) {
|
foreach($Folder in $Folders) {
|
||||||
$Repository = (Get-Item "$Folder").Name
|
$FolderName = (Get-Item "$Folder").Name
|
||||||
$LatestTagCommitID = (git -C "$Folder" rev-list --tags --max-count=1)
|
$LatestTagCommitID = (git -C "$Folder" rev-list --tags --max-count=1)
|
||||||
if ($LatestTagCommitID -ne "") {
|
if ($LatestTagCommitID -ne "") {
|
||||||
$LatestTag = (git -C "$Folder" describe --tags $LatestTagCommitID)
|
$LatestTag = (git -C "$Folder" describe --tags $LatestTagCommitID)
|
||||||
@ -36,7 +36,7 @@ function ListRepos {
|
|||||||
$Status = (git -C "$Folder" status --short)
|
$Status = (git -C "$Folder" status --short)
|
||||||
if ("$Status" -eq "") { $Status = "✔️clean" }
|
if ("$Status" -eq "") { $Status = "✔️clean" }
|
||||||
elseif ("$Status" -like " M *") { $Status = "⚠️modified" }
|
elseif ("$Status" -like " M *") { $Status = "⚠️modified" }
|
||||||
New-Object PSObject -property @{'Repository'="📂$Repository";'Latest Tag'="$LatestTag";'Branch'="$Branch";'Status'="$Status";'Remote'="$RemoteURL ↓$NumCommits";}
|
New-Object PSObject -property @{'Local Repo'="📂$FolderName";'Latest Tag'="$LatestTag";'Branch'="$Branch";'Status'="$Status";'Remote URL'="$RemoteURL ↓$NumCommits";}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,7 +46,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='Repository';width=20},@{e='Latest Tag';width=18},@{e='Branch';width=20},@{e='Status';width=10},Remote
|
ListRepos | Format-Table -property @{e='Local Repo';width=19},@{e='Latest Tag';width=18},@{e='Branch';width=20},@{e='Status';width=10},'Remote URL'
|
||||||
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