Skip to content

Migrate Set-Branch: switch/checkout branch with ShouldProcess #56

Description

@shmuelie

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

Goal

Add a command to switch/checkout a branch (ObjectiveGit's Set-Branch), with
-CreateNew, -Force, and -Track behavior — modernized.

Modernize (do not port as-is)

  • ObjectiveGit assembles a command string and runs it via Invoke-Expression
    ("git -C $Repository checkout$ExtendedCLI $Branch"). Use the shared helper
    with a git argument array instead.
  • Add [CmdletBinding(SupportsShouldProcess)] and honor -WhatIf/-Confirm
    (this changes working-tree state, and -Force can discard local changes).
  • Consider aligning with git switch / git switch -c semantics rather than
    raw checkout where it reads more clearly; keep the flag surface intuitive.
  • Cross-platform repository path handling.
  • Drop the magic exit-code / "Bug with ObjectiveGit" branch (handled by the
    helper).

Acceptance criteria

  • Exported from both the .psm1 and .psd1 export lists.
  • Comment-based help; SupportsShouldProcess honored.
  • Final command name uses an approved verb and fits the existing module surface
    (name open to discussion).
  • README command table + [Unreleased] CHANGELOG updated.
  • Deterministic Pester tests.
  • build/Test-Modules.ps1 and build/Invoke-Tests.ps1 pass.

Metadata

Metadata

Assignees

No one assigned

    Labels

    blockedCannot proceed until another issue or dependency is resolvedenhancementNew feature or requestmodule:gitChanges to Shmuelie.Gittheme:migrationMigration or modernization of an existing implementation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions