You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
NSPOSIXErrorDomain code=9 / EBADF from posix_spawn when reusing the shared FileHandle.nullDevice for stdin
Context
GitService.runand its helpers (makeProcess,attachDevNullStdin,waitForProcess,startDraining,awaitDrain) hand-roll Foundation'sProcessAPI. This has cost us a series of bugs that are non-issues with a higher-level abstraction:NSPOSIXErrorDomain code=9 / EBADFfromposix_spawnwhen reusing the sharedFileHandle.nullDevicefor stdinProposal
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)/dev/nullstdin managementGitError.processLaunchFailed(subsumed by Subprocess's error type)What stays
gitPathresolution,defaultTimeout,networkTimeoutvalidateRepository,repositoryName,currentBranch, and every higher-level command method that wrapsrunactorboundary onGitServiceAcceptance criteria
swift-subprocessadded as the project's first SPM dependency (Xcode → File → Add Package Dependencies)GitService.runreduced to ~10 lines usingSubprocess.run(...)git logoutput (the case from Loading a repository may timeout #4) and confirm no timeoutNotes
swift-subprocessis pre-1.0 as of writing; pin to a specific version in the Xcode dependency dialog so future API changes don't surprise us