Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Plugins/Tia/ChangedFiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ private function workingTreeChanges(): array
$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] !== '') {
Expand Down
26 changes: 26 additions & 0 deletions tests/Features/Tia/WorktreeRename.php
Original file line number Diff line number Diff line change
@@ -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');
});