fix(tia): report git errors instead of a missing dependency (#1987)

* fix(tia): show git's error instead of asking to install git when it fails

* fix(tia): detect a missing git binary with ExecutableFinder

Only report MissingDependency when git can't be found on PATH or there
is no repository. Any other failure shows git's error output, or the
exit code when git printed nothing.

---------

Co-authored-by: Mohannad Elemary <20709195+MohannadElemary@users.noreply.github.com>
Co-authored-by: Punyapal Shah <53343069+MrPunyapal@users.noreply.github.com>
This commit is contained in:
Mohannad Elemary
2026-11-13 17:13:41 +02:00
committed by GitHub
parent 1fbd63dbb3
commit 98e96a8f5c
5 changed files with 165 additions and 19 deletions
+50
View File
@@ -0,0 +1,50 @@
<?php
declare(strict_types=1);
namespace Pest\Exceptions;
use NunoMaduro\Collision\Contracts\RenderlessEditor;
use NunoMaduro\Collision\Contracts\RenderlessTrace;
use Pest\Contracts\Panicable;
use RuntimeException;
use Symfony\Component\Console\Exception\ExceptionInterface;
use Symfony\Component\Console\Formatter\OutputFormatter;
use Symfony\Component\Console\Output\OutputInterface;
/**
* @internal
*/
final class TiaGitFailed extends RuntimeException implements ExceptionInterface, Panicable, RenderlessEditor, RenderlessTrace
{
public function __construct(private readonly string $error)
{
parent::__construct(sprintf('Tia mode could not read the git repository: %s', $this->error));
}
public function render(OutputInterface $output): void
{
$output->writeln([
'',
' <fg=white;options=bold;bg=red> ERROR </> Tia mode could not read the git repository.',
'',
' Git is installed, but it failed with:',
'',
]);
foreach (explode("\n", $this->error) as $line) {
$output->writeln(' <fg=yellow>'.OutputFormatter::escape(rtrim($line)).'</>');
}
$output->writeln([
'',
' Runs without <fg=yellow>--tia</> are unaffected.',
'',
]);
}
public function exitCode(): int
{
return 1;
}
}