Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a “locally tracked” safeguard to the module installer so that modules with an existing .git directory are not overwritten during install() or update(), while still keeping Composer’s installed-repository state consistent. It also adds PHPUnit coverage to verify the skip behavior and messaging.
Changes:
- Add a locally-tracked guard to
Installer::install()that skips installation when the install path is locally tracked and ensures the package is registered in the installed repo. - Add a locally-tracked guard to
Installer::update()that skips updating when the install path is locally tracked, while replacing the repo entry from$initialto$target. - Add tests covering the install/update skip behavior for
.git-present install paths.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/Installer.php |
Adds locally-tracked early-return guards to install() and update() and adjusts repo bookkeeping when skipping. |
tests/ModuleInstallerTest.php |
Adds tests validating that install/update are skipped for locally tracked install paths and the expected messages/repo updates occur. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return \React\Promise\resolve(null); | ||
| } | ||
|
|
||
| if ($this->isLocallyTracked($this->getInstallPath($package))) { |
|
|
||
| $installPath = $this->getInstallPath($target); | ||
|
|
||
| if ($this->isLocallyTracked($installPath)) { |
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 introduces logic to skip installation and updating of modules that are locally tracked (i.e., have a
.gitdirectory), preventing Composer from overwriting local changes. Comprehensive tests are also added to ensure this behavior.Installer logic improvements
src/Installer.php: Theinstallandupdatemethods now detect if a module is locally tracked (by checking for a.gitdirectory) and skip installation or update for such modules, logging a message to the user and ensuring repository state is consistent. [1] [2]Test coverage
tests/ModuleInstallerTest.php: Addedtest_install_skips_when_install_path_is_locally_trackedto verify that installation is skipped for locally tracked modules and the correct message is output.tests/ModuleInstallerTest.php: Addedtest_update_skips_when_install_path_is_locally_trackedto verify that updates are skipped for locally tracked modules, the repository is updated appropriately, and the correct message is output.