mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-04-23 18:38:19 +02:00
Update list-repos.ps1
This commit is contained in:
parent
d1e225fa2a
commit
0dd2d484c5
@ -6,10 +6,10 @@
|
|||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./list-repos C:\MyRepos
|
PS> ./list-repos C:\MyRepos
|
||||||
|
|
||||||
Folder Branch Status
|
Repository Branch Status
|
||||||
------ ------ ------
|
------ ------ ------
|
||||||
cmake main clean
|
cmake main clean
|
||||||
opencv master clean
|
opencv master clean
|
||||||
...
|
...
|
||||||
.NOTES
|
.NOTES
|
||||||
Author: Markus Fleschutz · License: CC0
|
Author: Markus Fleschutz · License: CC0
|
||||||
@ -22,12 +22,12 @@ param([string]$ParentDir = "$PWD")
|
|||||||
function ListRepos { param([string]$ParentDir)
|
function ListRepos { param([string]$ParentDir)
|
||||||
$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
|
$Repository = (get-item "$Folder").Name
|
||||||
$Branch = (git -C "$Folder" branch --show-current)
|
$Branch = (git -C "$Folder" branch --show-current)
|
||||||
$Status = (git -C "$Folder" status --short)
|
$Status = (git -C "$Folder" status --short)
|
||||||
if ("$Status" -eq "") { $Status = "clean" }
|
if ("$Status" -eq "") { $Status = "clean" }
|
||||||
|
|
||||||
New-Object PSObject -property @{ 'Folder'="$FolderName"; 'Branch'="$Branch"; 'Status'="$Status"; }
|
New-Object PSObject -property @{ 'Repository'="$Repository"; 'Branch'="$Branch"; 'Status'="$Status"; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,7 +37,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 Folder,Branch,Status
|
ListRepos | format-table -property Repository,Branch,Status
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||||
|
Loading…
Reference in New Issue
Block a user