Skip to content

Migrate GitService.run from Process to swift-subprocess #7

@poolcamacho

Description

@poolcamacho

Context

GitService.run and its helpers (makeProcess, attachDevNullStdin, waitForProcess, startDraining, awaitDrain) hand-roll Foundation's Process API. This has cost us a series of bugs that are non-issues with a higher-level abstraction:

Proposal

Migrate to swift-subprocess, the swiftlang-org package designed exactly for this use case. Suggested by @just-doit in #4 along with the relevant Apple Developer Forums thread: https://developer.apple.com/forums/thread/690310.

What goes away

  • makeProcess, attachDevNullStdin, waitForProcess, startDraining, awaitDrain (the entire helper layer)
  • The continuation + polling loop
  • Manual /dev/null stdin management
  • Manual pipe drain and close
  • GitError.processLaunchFailed (subsumed by Subprocess's error type)

What stays

  • gitPath resolution, defaultTimeout, networkTimeout
  • validateRepository, repositoryName, currentBranch, and every higher-level command method that wraps run
  • The actor boundary on GitService

Acceptance criteria

  • swift-subprocess added as the project's first SPM dependency (Xcode → File → Add Package Dependencies)
  • GitService.run reduced to ~10 lines using Subprocess.run(...)
  • All existing call sites work unchanged (signature preserved)
  • Build clean, SwiftLint clean
  • Manual smoke test: open a repo with > 64KB of git log output (the case from Loading a repository may timeout #4) and confirm no timeout

Notes

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions