Public/Get-GitRepositoryInfos.ps1
# Remove-Folder C:\src\Beispiele @("node_modules", "npm-cache") #$ErrorActionPreference = 'Stop' # https://github.com/microsoft/PowerShellForGitHub class RepositoryInfo { # Optionally, add attributes to prevent invalid values [ValidateNotNullOrEmpty()][string]$Name [ValidateNotNullOrEmpty()][string]$State [ValidateNotNullOrEmpty()][System.IO.DirectoryInfo]$DirectoryInfo [string]$RemoteOrigin [ValidateNotNullOrEmpty()][bool]$Commit [ValidateNotNullOrEmpty()][bool]$Push [ValidateNotNullOrEmpty()][bool]$Local [ValidateNotNullOrEmpty()][string]$FullName } function Get-GitRepositoryInfos { [CmdletBinding()] [OutputType([RepositoryInfo[]])] Param( [string]$Path = $pwd ) $result = @() #New-Object System.Collections.ArrayList Clear-Host $repos = Get-GitRepositories $Path foreach ($item in $repos) { $status = Get-GitRepositoryState $item $commitRequired = Get-GitCommitRequired $status $pushRequired = Get-GitPushRequired $item $remoteOrigin = $(Get-GitRemoteOrigin $item) $currentRepo = [RepositoryInfo]@{ Name = $item.Name DirectoryInfo = $item State = $status Commit = $commitRequired Push = $pushRequired RemoteOrigin = $remoteOrigin Local = [string]::IsNullOrEmpty($remoteOrigin) FullName = $item.FullName } $result += $currentRepo } return $result } # Get only repos without remote: | Where-Object { $_.Local -eq $true} # Get only repos where commit is required: | Where-Object { $_.Commit -eq $true} # Get only repos where psuh is required: | Where-Object { $_.Push -eq $true} # Get-GitRepositoryInfos C:\src\g-dotup | Where-Object { $_.Commit -eq $true } | Format-Table -Property Name, State, Commit, Push, Local, RemoteOrigin, FullName # c:\temp |