Conversation
… and real directory for path dist types
There was a problem hiding this comment.
Pull request overview
This PR tightens the installer’s “path repository” detection so modules are only treated as path repos when they are actually backed by a symlinked path checkout (or a git-tracked working copy), and updates the test suite to validate this behavior using more realistic filesystem layouts.
Changes:
- Refines
Installer::isPathRepository()to requiredistType === 'path'and evidence of a real path repo on disk (symlink or.gitpresence). - Introduces a
TestableInstaller::$forcePathRepositoryoverride hook to explicitly control path-repo behavior in install/update/uninstall tests. - Rewrites/expands
isPathRepositorytests to exercise symlink, real directory, missing path, and.gitdirectory scenarios.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/Installer.php |
Updates path-repository detection to avoid misclassifying normal directories as path repos. |
tests/ModuleInstallerTest.php |
Adds a test hook and updates tests to reflect and validate the refined detection logic with real FS fixtures. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+294
to
+298
| $path = $this->getInstallPath($package); | ||
|
|
||
| // Genuine path repos: OS symlink (symlink:true) OR a git-tracked dev clone (.git present). | ||
| // Packagist-installed modules have .git removed by DEFAULT_EXCLUDED_DIRS — they are neither. | ||
| return is_link($path) || is_dir($path.'/.git'); |
Comment on lines
+590
to
+592
| $installer = new TestableInstaller($this->createStub(IOInterface::class), null); | ||
| $pkg = new Package('saucebase/nonexistent-module', '1.0.0.0', '1.0.0'); | ||
| $pkg->setDistType('path'); |
| $baseDir = sys_get_temp_dir().'/path-repo-symlink-'.uniqid('', true); | ||
| $target = $baseDir.'/source'; | ||
| mkdir($target, 0755, true); | ||
| symlink($target, $baseDir.'/test-module'); |
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.
This pull request refines the detection of "path repositories" in the installer logic and significantly improves the reliability and realism of related test cases. The main change is that a package is now only considered a path repository if its install path is an OS symlink or contains a
.gitdirectory, not just by havingdistType === 'path'. The test suite is updated to reflect and verify this behavior, introducing more realistic filesystem scenarios and a new test helper for controlling path repository detection.Installer logic improvements:
isPathRepositorymethod inInstaller.phpnow checks that the install path is either an OS symlink or contains a.gitdirectory, in addition to havingdistType === 'path'. This prevents misidentifying regular directories as path repositories.Test infrastructure enhancements:
TestableInstallerinModuleInstallerTest.phpadds aforcePathRepositoryproperty and overridesisPathRepository, allowing tests to explicitly simulate path repository detection when needed.Test suite updates:
isPathRepositorytest cases are rewritten to use real filesystem structures (symlinks,.gitdirectories, and real directories) to accurately reflect real-world scenarios. Additional tests are added to cover all relevant cases.getDistTypeto'path'now use theforcePathRepositoryproperty for explicit and consistent test behavior. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12]