From a22a25c513ac8b9d9593b19687504212a84521ff Mon Sep 17 00:00:00 2001 From: roble Date: Sat, 6 Jun 2026 09:44:23 +0100 Subject: [PATCH] refactor: simplify isPathRepository logic and introduce isLocallyTracked method for clarity --- src/Installer.php | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/Installer.php b/src/Installer.php index 4ace505..5fd8b2c 100644 --- a/src/Installer.php +++ b/src/Installer.php @@ -281,9 +281,6 @@ protected function mergeStash(string $stash, string $base, string $install): voi * Returns true when the package is served by a local path repository. * Path repos have source == install path, so the normal download/delete cycle would * wipe the user's files before trying to copy from the now-missing source. - * - * With symlink:true, a genuine path repo creates a real OS symlink. A module installed - * from Packagist into the same directory is a real directory — not a true path repo. */ protected function isPathRepository(PackageInterface $package): bool { @@ -291,9 +288,19 @@ protected function isPathRepository(PackageInterface $package): bool return false; } - $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 $this->isLocallyTracked($this->getInstallPath($package)); + } + + /** + * Returns true when the install path is a locally-managed directory that should never + * be overwritten by the installer — either an OS symlink (path repo with symlink:true) + * or a git-tracked dev clone (.git present). + * + * Packagist-installed modules have .git removed by DEFAULT_EXCLUDED_DIRS, so they never + * match this check and remain updateable from Packagist. + */ + protected function isLocallyTracked(string $path): bool + { return is_link($path) || is_dir($path.'/.git'); }