Repository navigation
Conversation
Tia refused to run whenever the Pest project was not the git repository root, because git prints and addresses paths relative to the repository root while the dependency graph is keyed on project-relative paths. Translate at every git boundary instead of guarding against the mismatch. `Git::pathPrefix()` resolves the directory of the project inside the repository, and `ChangedFiles` strips that prefix off the paths git prints, drops the paths of sibling packages, and prepends it to `git show`. Both diffs read `-z` records, because `core.quotePath` C-quotes a path outside ASCII, and `--no-relative` holds the frame when a user sets `diff.relative`. Three places read `<projectRoot>/.git` directly, which is absent in a nested project and in a worktree, and now ask git: `BaseRemote`, `Storage` and `Fingerprint::isTrackedByGit()`. `Storage` folds the prefix into the state key so two projects in one repository do not share a graph, and the fingerprint carries the prefix so a baseline published by a sibling project is rejected. A project at the repository root keeps the key and the fingerprint it had. `git check-ignore` runs without `--no-index`, so a tracked file that an ignore rule matches counts as part of the project on both sides of the boundary. Changes outside the project are dropped and reported by count in the run summary, so a nested project does not look idle when the repository around it moved. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
# Conflicts: # src/Plugins/Tia/Baselines/BaseRemote.php
|
Looking forward to this, so that we can also reap the benefits of TIA in our project! |
|
@nunomaduro @calebdw can you review this? |
They are already acting by closing the other PRs in favour of this one. They're on it :) |
|
This will be great once merged. We could start using TIA |
|
I don't want to annoy anyone but we also have multiple projects waiting for this improvement 😇 |
|
I'm also looking forward to these changes being merged |
|
Please update this branch against the latest |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
done @MrPunyapal |
MrPunyapal
left a comment
There was a problem hiding this comment.
Please cover two cases where TIA replays passing results after a dependency changes. I reproduced both against the merge preview. TIA replayed all six tests and exited 0, while the full suite failed.
- A project in a directory named
backendloses the leading space in its Git prefix. Preserve the prefix exactly apart from Git's line ending, and test a change inside that directory. - A project can load PHP from a sibling directory. Ignoring all changes outside the project can hide failures in that code. Run the full suite when an outside change might affect the project, and add a regression that changes a shared PHP dependency.
|
@MrPunyapal Thanks for the reproduction. Point 1 is fixed in e1e6314. The cause
The fix Both methods now read git through Tests
Each test fails on the previous code. Point 2 Point 2, the code that a nested project loads from outside its root, is fixed in #1915, which builds on this branch. Do you want me to bring that fix into this PR so you can review both points in one place, or do you prefer to keep them as two PRs? |
What happens
Run
vendor/bin/pest --tiain a Pest project that sits below the root of its git repository,backend/in a monorepo for example, and Tia refuses:Git prints and addresses every path relative to the repository root,
backend/app/Service.php, while the dependency graph keys its edges on paths relative to the project root,app/Service.php. The plugin guarded against the mismatch instead of translating it.Related: #1805, #1809, #1820.
The fix
Translate at every place where Tia talks to git, and let a project at the repository root keep the paths, the state key and the fingerprint it has today.
Git::pathPrefix()returns the directory of the project inside the repository,backend/, or an empty string at the root or without git.ChangedFilesstrips that prefix off the output ofgit diff --name-onlyandgit status --porcelain, drops the paths of sibling packages, and prepends it togit show <sha>:<path>. Both reads take-zrecords, becausecore.quotePathC-quotes a path outside ASCII, and--no-relativekeeps the repository frame when the user setsdiff.relative.git check-ignoreruns without--no-index, so a tracked file that an ignore rule matches still counts as part of the project.<projectRoot>/.gitdirectly, which is absent in a nested project and in a worktree, and now ask git:BaseRemote::readOriginUrl(),StorageandFingerprint::isTrackedByGit().Storagefolds the prefix into the state key, so two projects in one repository do not share a graph. The key of a project at the repository root does not change.TiaRequiresRepositoryRootand the test that expected it go away.Tests
tests/Features/Tia/Monorepo.phpruns a nested project through replay, a working tree change, a committed change, a sibling change, an undone commit, two projects in one repository, and remote baselines for a nested project.tests/Unit/Plugins/Tia/ChangedFiles.phpcovers the path translation, the ignore rules on both sides of the boundary, non-ASCII paths anddiff.relative.tests/Unit/Plugins/Tia/Storage.phpcovers the state key.pest --group=tia: 222 passed.A second pull request builds on this one and makes Tia see the code a nested project loads from outside its root, such as a Composer path repository or a sibling package.
🤖 Generated with Claude Code