fix(tia): detect renames in both porcelain status columns (#2017)

* fix(tia): detect renames in both porcelain status columns

git status --porcelain emits worktree renames as " R new\0old". The parser only checked the first status column, so the paired source path was read as a standalone record and truncated by substr(3). The broken path then made git check-ignore exit 128, which surfaced as MissingDependency("Tia mode", "git").

* Fix worktree rename test style

---------

Co-authored-by: Punyapal Shah <53343069+MrPunyapal@users.noreply.github.com>
Co-authored-by: Punyapal Shah <mrpunyapal@gmail.com>
This commit is contained in:
Cy(rod) John
2026-11-13 22:48:16 +08:00
committed by GitHub
parent 8e3f467d8a
commit 1fbd63dbb3
2 changed files with 27 additions and 1 deletions
+1 -1
View File
@@ -359,7 +359,7 @@ final readonly class ChangedFiles
$status = substr($record, 0, 2);
$path = substr($record, 3);
if ($status[0] === 'R' || $status[0] === 'C') {
if (str_contains($status, 'R') || str_contains($status, 'C')) {
$files[] = $path;
if (isset($records[$i + 1]) && $records[$i + 1] !== '') {
+26
View File
@@ -0,0 +1,26 @@
<?php
declare(strict_types=1);
use Pest\Plugins\Tia\ChangedFiles;
use Tests\Fixtures\Tia\Project;
afterEach(function (): void {
Project::destroyAll();
});
test('a worktree rename recorded as intent-to-add keeps both paths', function (): void {
$project = Project::make('master');
$project->write('app/Stub.php', 'same content');
$project->git()->commit('add a file that will be moved');
$project->write('lib/Stub.php', 'same content');
$project->git()->run(['add', '-N', 'lib/Stub.php']);
unlink($project->path('app/Stub.php'));
$changed = new ChangedFiles($project->path())->since(null);
expect($changed)->toContain('app/Stub.php')
->and($changed)->toContain('lib/Stub.php');
});