Skip to content

Add Repository::runProcess() to expose stderr on successful commands - #247

Merged
lyrixx merged 1 commit into
mainfrom
worktree-issue-205-stderr
Sep 7, 2026
Merged

Add Repository::runProcess() to expose stderr on successful commands#247
lyrixx merged 1 commit into
mainfrom
worktree-issue-205-stderr

Conversation

@lyrixx

@lyrixx lyrixx commented Sep 7, 2026

Copy link
Copy Markdown
Member

Summary

Repository::run() only ever returns stdout, even when the process succeeds. Some git commands (push, in particular) write their meaningful output to stderr even on success, so callers had no way to read it.

Fixes #205.

Changes

  • Extracted the process-running logic (logging, debug output, error handling) out of run() into a new public method runProcess(), which returns the full, already-run Symfony\Component\Process\Process instead of just stdout.
  • run() now delegates to runProcess() and keeps its exact original behavior (stdout-only, null on failure, throws in debug mode) — fully backward compatible.
  • Callers who need stderr (e.g. for push) can now do:
    $process = $repository->runProcess('push', ['origin', 'main']);
    $process->getErrorOutput();

Test plan

  • Added tests covering runProcess() exposing stderr on success and returning a failed (non-throwing) process when debug is off
  • Full test suite passes (vendor/bin/phpunit)
  • PHPStan level 9 clean
  • php-cs-fixer clean

Repository::run() only ever returns stdout, even on success. Some git
commands (push, in particular) write their meaningful output to stderr
even when they succeed, so callers had no way to read it (#205).

runProcess() returns the full, already-run Process instead, giving
access to getErrorOutput(). run() now delegates to it and keeps its
exact original behavior.
@lyrixx
lyrixx merged commit b5cffd7 into main Sep 7, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Library takes stdout into consideration only

1 participant