mirror of
https://github.com/pestphp/pest.git
synced 2026-12-03 22:45:06 +01:00
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:
@@ -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] !== '') {
|
||||
|
||||
@@ -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');
|
||||
});
|
||||
Reference in New Issue
Block a user