Skip to content

Migrate Restore-Items: restore working-tree files (argument array, ShouldProcess) #60

Description

@shmuelie

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

Goal

Add a command to restore working-tree files (ObjectiveGit's Restore-Items),
with -Force and -Source — modernized.

Modernize (do not port as-is)

  • ObjectiveGit builds "git -C $Repository checkout$ExtendedCLI -- $Files" and
    runs it via Invoke-Expression — with a [string[]]$Files interpolated into
    the command string, this is a real argument-injection/quoting hazard. Use the
    shared helper with a git argument array and pass file paths as discrete
    arguments after --.
  • This is destructive (overwrites working-tree files): add
    [CmdletBinding(SupportsShouldProcess)]; honor -WhatIf/-Confirm.
  • Consider git restore (with --source/--staged as appropriate) over raw
    checkout -- <paths> for clearer intent.
  • Cross-platform path handling; drop the magic exit-code / bug branch.

Acceptance criteria

  • Exported from both the .psm1 and .psd1 export lists.
  • Comment-based help; SupportsShouldProcess honored.
  • File paths passed as an argument array (never interpolated into a command
    string); final command name uses an approved verb.
  • README command table + [Unreleased] CHANGELOG updated.
  • Deterministic Pester tests (temp repo; assert paths with spaces/special chars
    are handled and -WhatIf makes no changes).
  • 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 implementationtheme:securityInput validation, injection, permissions, or hardening

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions