diff --git a/src/Indexer.php b/src/Indexer.php index 34ad618f..00043cbd 100644 --- a/src/Indexer.php +++ b/src/Indexer.php @@ -149,15 +149,23 @@ public function index(): Promise $cacheKey = null; $index = null; foreach (array_merge($this->composerLock->packages, $this->composerLock->{'packages-dev'}) as $package) { - // Check if package name matches and version is absolute - // Dynamic constraints are not cached, because they can change every time + // Check if package can be cached. $packageVersion = ltrim($package->version, 'v'); + // If package is anchored to a version if ($package->name === $packageName && strpos($packageVersion, 'dev') === false) { $packageKey = $packageName . ':' . $packageVersion; $cacheKey = self::CACHE_VERSION . ':' . $packageKey; // Check cache $index = yield $this->cache->get($cacheKey); break; + + // If package is checked out + } elseif ($package->name === $packageName && isset($package->source->reference)) { + $packageKey = $packageName . ':' . $package->source->reference; + $cacheKey = self::CACHE_VERSION . ':' . $packageKey; + // Check cache + $index = yield $this->cache->get($cacheKey); + break; } } if ($index !== null) {