diff --git a/src/Plugins/Tia/Baselines/BaseRemote.php b/src/Plugins/Tia/Baselines/BaseRemote.php index 5e90b13d..969821d3 100644 --- a/src/Plugins/Tia/Baselines/BaseRemote.php +++ b/src/Plugins/Tia/Baselines/BaseRemote.php @@ -105,13 +105,9 @@ abstract readonly class BaseRemote // @pest-arch-ignore-line return $configured; } - $process = new Process(['git', 'symbolic-ref', 'refs/remotes/origin/HEAD']); - $process->setTimeout(5.0); - $process->run(); - - if ($process->isSuccessful()) { - $ref = trim($process->getOutput()); + $ref = new Git()->output(['symbolic-ref', 'refs/remotes/origin/HEAD']); + if ($ref !== null) { $branch = str_replace('refs/remotes/origin/', '', $ref); if ($branch !== '') { diff --git a/src/Plugins/Tia/Fingerprint.php b/src/Plugins/Tia/Fingerprint.php index 236e2e06..149cf419 100644 --- a/src/Plugins/Tia/Fingerprint.php +++ b/src/Plugins/Tia/Fingerprint.php @@ -7,7 +7,6 @@ namespace Pest\Plugins\Tia; use Pest\Plugins\Tia\Contracts\Lockfile; use Pest\Support\Git; use Symfony\Component\Process\Exception\ExceptionInterface as ProcessException; -use Symfony\Component\Process\Process; /** * @internal @@ -302,16 +301,11 @@ final readonly class Fingerprint return $cache[$key] = true; } - $process = new Process(['git', 'check-ignore', '-q', '--', $relativePath], $projectRoot); - $process->setTimeout(5.0); - try { - $process->run(); + return $cache[$key] = ! new Git($projectRoot)->succeeds(['check-ignore', '-q', '--', $relativePath]); } catch (ProcessException) { return $cache[$key] = true; } - - return $cache[$key] = $process->getExitCode() !== 0; } private static function projectPrefix(string $projectRoot): string diff --git a/src/Support/Git.php b/src/Support/Git.php index a139be1d..863a193e 100644 --- a/src/Support/Git.php +++ b/src/Support/Git.php @@ -79,7 +79,7 @@ final readonly class Git */ public function result(array $arguments, ?string $input = null): array { - $process = new Process(['git', ...$arguments], $this->directory); + $process = new Process(['git', ...$arguments], $this->directory, ['LC_ALL' => 'C', 'LANGUAGE' => '']); $process->setTimeout($this->timeout); if ($input !== null) { diff --git a/tests/Features/Tia/DefaultBranchResolution.php b/tests/Features/Tia/DefaultBranchResolution.php index b9b2fb94..0bd050b6 100644 --- a/tests/Features/Tia/DefaultBranchResolution.php +++ b/tests/Features/Tia/DefaultBranchResolution.php @@ -179,6 +179,19 @@ test('tia still requires git', function (): void { ->and($result->exitCode)->not->toBe(0); })->skipOnWindows(); +test('tia still requires git when git speaks another language', function (): void { + $project = Project::withoutGit(); + + $result = $project->pestWithEnvironment($project->path(), [ + 'LC_ALL' => 'es_ES.UTF-8', + 'LANG' => 'es_ES.UTF-8', + 'LANGUAGE' => 'es', + ], '--tia'); + + expect($result->output)->toContain('The [Tia mode] feature requires [git].') + ->and($result->exitCode)->toBe(1, $result->describe()); +})->skipOnWindows(); + test('a failing git shows its own error instead of asking for git', function (): void { $project = Project::make('master');