Skip to content

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

Open
cyrodjohn wants to merge 2 commits into
pestphp:5.xfrom
cyrodjohn:fix/tia-worktree-renames
Open

cyrodjohn wants to merge 2 commits into
pestphp:5.xfrom
cyrodjohn:fix/tia-worktree-renames

Conversation

@cyrodjohn

Copy link
Copy Markdown

What:

  • Bug Fix
  • New Feature

Description:

pest --tia stops before it runs a test and prints MissingDependency: The [Tia mode] feature requires [git]. Please install it and try again. when the working tree contains a rename that git reports in the second status column.

Plain git reproduction:

git init repro && cd repro
mkdir -p A Q
echo 'same content' > A/File.php
git add . && git commit -m init

echo 'same content' > Q/File.php
git add -N Q/File.php
rm A/File.php

git status --porcelain -z then prints R Q/File.php\0A/File.php. The R sits in the second column.

ChangedFiles::workingTreeChanges() only checks $status[0], so it skips the rename branch. It adds the destination path and reads the source path as its own record, and substr($record, 3) turns app/A.php into /A.php. filterIgnored() passes that path to git check-ignore, git exits with code 128, and any exit code other than 0 or 1 becomes MissingDependency('Tia mode', 'git').

Fix

if (str_contains($status, 'R') || str_contains($status, 'C')) {

Test

tests/Features/Tia/WorktreeRename.php builds the repository shape above and asserts that both paths remain in the changed file list. It fails on 5.x and passes with this change.

Verification

  • php bin/pest tests/Features/Tia/WorktreeRename.php fails before the change and passes after it.
  • The same change was applied to a project with 2569 tests where the failure reproduced. TIA then ran and reported the affected test files.

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").
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant