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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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