From 3cff4a3bb977c2ba9a09204690da128c7dceb092 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 24 Feb 2015 13:07:28 +0000 Subject: [PATCH] Check for homepages in local repo first if available to make the home command faster --- src/Composer/Command/HomeCommand.php | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/src/Composer/Command/HomeCommand.php b/src/Composer/Command/HomeCommand.php index 7dd8113cb..5ea193d5c 100644 --- a/src/Composer/Command/HomeCommand.php +++ b/src/Composer/Command/HomeCommand.php @@ -57,10 +57,16 @@ EOT */ protected function execute(InputInterface $input, OutputInterface $output) { - $repo = $this->initializeRepo(); + $repos = $this->initializeRepos(); $return = 0; foreach ($input->getArgument('packages') as $packageName) { + foreach ($repos as $repo) { + $package = $this->getPackage($repo, $packageName); + if ($package instanceof CompletePackageInterface) { + break; + } + } $package = $this->getPackage($repo, $packageName); if (!$package instanceof CompletePackageInterface) { @@ -144,21 +150,25 @@ EOT } /** - * Initializes the repo + * Initializes repositories * - * @return CompositeRepository + * Returns an array of repos in order they should be checked in + * + * @return RepositoryInterface[] */ - private function initializeRepo() + private function initializeRepos() { $composer = $this->getComposer(false); if ($composer) { - $repo = new CompositeRepository($composer->getRepositoryManager()->getRepositories()); - } else { - $defaultRepos = Factory::createDefaultRepositories($this->getIO()); - $repo = new CompositeRepository($defaultRepos); + return array( + $composer->getRepositoryManager()->getLocalRepository(), + new CompositeRepository($composer->getRepositoryManager()->getRepositories()) + ); } - return $repo; + $defaultRepos = Factory::createDefaultRepositories($this->getIO()); + + return array(new CompositeRepository($defaultRepos)); } }