Public/Get-GitWorktreeStatus.ps1

<#
.SYNOPSIS
    Returns the status of all worktrees in the current repository.
.DESCRIPTION
    For each worktree, reports the branch name, path, and how many uncommitted
    changes are present. The bare repo entry is included with Changes = 0.
.OUTPUTS
    Array of PSCustomObjects with: Branch, Path, IsBare, Changes
.EXAMPLE
    Get-GitWorktreeStatus
.EXAMPLE
    Get-GitWorktreeStatus | Where-Object Changes -gt 0
    # Show only dirty worktrees
#>

function Get-GitWorktreeStatus {
    [CmdletBinding()]
    [OutputType([PSCustomObject[]])]
    param(
        [string] $RepoPath = (Get-Location).Path
    )

    $root      = Get-GitRoot -Path $RepoPath
    $worktrees = Get-WorktreeList -RepoPath $root

    foreach ($wt in $worktrees) {
        $changes = 0
        if (-not $wt.IsBare) {
            $statusLines = git -C $wt.Path status --porcelain 2>$null
            if ($statusLines) {
                $changes = @($statusLines).Count
            }
        }

        [PSCustomObject]@{
            Branch  = if ($wt.Branch) { $wt.Branch } else { '(bare)' }
            Path    = $wt.Path
            IsBare  = $wt.IsBare
            Changes = $changes
        }
    }
}