Skip to content

feat: enhance isPathRepository logic to differentiate between symlink…#15

Merged
roble merged 2 commits into
mainfrom
dev
Jun 5, 2026
Merged

feat: enhance isPathRepository logic to differentiate between symlink…#15
roble merged 2 commits into
mainfrom
dev

Conversation

@roble

@roble roble commented Jun 5, 2026

Copy link
Copy Markdown
Collaborator

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 .git directory, not just by having distType === '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:

  • The isPathRepository method in Installer.php now checks that the install path is either an OS symlink or contains a .git directory, in addition to having distType === 'path'. This prevents misidentifying regular directories as path repositories.

Test infrastructure enhancements:

  • TestableInstaller in ModuleInstallerTest.php adds a forcePathRepository property and overrides isPathRepository, allowing tests to explicitly simulate path repository detection when needed.

Test suite updates:

  • The isPathRepository test cases are rewritten to use real filesystem structures (symlinks, .git directories, and real directories) to accurately reflect real-world scenarios. Additional tests are added to cover all relevant cases.
  • All tests that previously relied on stubbing getDistType to 'path' now use the forcePathRepository property for explicit and consistent test behavior. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12]

Copilot AI review requested due to automatic review settings June 5, 2026 20:32
@roble roble merged commit 15f38a7 into main Jun 5, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 require distType === 'path' and evidence of a real path repo on disk (symlink or .git presence).
  • Introduces a TestableInstaller::$forcePathRepository override hook to explicitly control path-repo behavior in install/update/uninstall tests.
  • Rewrites/expands isPathRepository tests to exercise symlink, real directory, missing path, and .git directory 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 thread src/Installer.php
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');
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.

2 participants