Skip to content

Migrate Get-Branch: list branches via for-each-ref with typed output #55

Description

@shmuelie

Part of #52. Depends on the shared git-invocation helper sub-issue.

Goal

Add a Get-Branch command to Shmuelie.Git that lists local and remote
branches with tracking info, emitting a typed object — modernizing
ObjectiveGit's Get-Branch.

Modernize (do not port as-is)

  • ObjectiveGit scrapes git branch --no-color -vv --no-abbrev (and -r) with a
    stack of fragile regexes. Replace with a machine-readable format:
    git for-each-ref --format=... (or --porcelain-style), consistent with the
    hardening in Harden git output parsing: porcelain rename/quotePath (tab completion) and locale-dependent fetch classification #33 (handle quotePath/rename/unusual ref names).
  • Return a typed object (like Get-Worktrees / Get-GitStatusSummary), not an
    ad-hoc PSCustomObject shape.
  • Cross-platform repository path handling (no '.\' string default; use
    Join-Path/[System.IO.Path]).

Suggested shape

Per-branch: name, whether current, commit hash, upstream/tracks, ahead/behind,
symbolic target (for HEAD -> ...), local vs remote, last commit subject.

Acceptance criteria

  • Exported from both the .psm1 Export-ModuleMember list and the .psd1
    FunctionsToExport list.
  • Comment-based help.
  • Uses the shared git-invocation helper; no Invoke-Expression.
  • Works on non-Windows PowerShell 7.
  • README command table + modules/Shmuelie.Git/CHANGELOG.md [Unreleased]
    updated.
  • Deterministic Pester tests (synthetic branch data / $TestDrive temp repo
    only where needed).
  • build/Test-Modules.ps1 and build/Invoke-Tests.ps1 pass.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions