fix(tia): run git in the C locale so Pest reads its messages in any language (#2074)

Co-authored-by: Punyapal Shah <53343069+MrPunyapal@users.noreply.github.com>
This commit is contained in:
Jhon Farias
2026-11-26 15:09:28 +01:00
committed by GitHub
parent dc73ec009e
commit 12f3cd80de
4 changed files with 17 additions and 14 deletions
+2 -6
View File
@@ -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 !== '') {
+1 -7
View File
@@ -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
+1 -1
View File
@@ -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) {
@@ -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');