From 471b012e3ae6ec93c5ad439c01538ffa984c5b9b Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 22 Jan 2018 13:41:32 +0100 Subject: [PATCH 1/6] Fix problem report when requiring "ext-zend opcache", refs #2509 --- src/Composer/DependencyResolver/Problem.php | 4 ++++ src/Composer/Repository/PlatformRepository.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Composer/DependencyResolver/Problem.php b/src/Composer/DependencyResolver/Problem.php index 15815be59..ba9eb9774 100644 --- a/src/Composer/DependencyResolver/Problem.php +++ b/src/Composer/DependencyResolver/Problem.php @@ -108,6 +108,10 @@ class Problem // handle php extensions if (0 === stripos($job['packageName'], 'ext-')) { + if (false !== strpos($job['packageName'], ' ')) { + return "\n - The requested PHP extension ".$job['packageName'].' should be required as '.str_replace(' ', '-', $job['packageName']).'.'; + } + $ext = substr($job['packageName'], 4); $error = extension_loaded($ext) ? 'has the wrong version ('.(phpversion($ext) ?: '0').') installed' : 'is missing from your system'; diff --git a/src/Composer/Repository/PlatformRepository.php b/src/Composer/Repository/PlatformRepository.php index 02d40e9a4..da5c9ab73 100644 --- a/src/Composer/Repository/PlatformRepository.php +++ b/src/Composer/Repository/PlatformRepository.php @@ -24,7 +24,7 @@ use Composer\Util\Silencer; */ class PlatformRepository extends ArrayRepository { - const PLATFORM_PACKAGE_REGEX = '{^(?:php(?:-64bit|-ipv6|-zts|-debug)?|hhvm|(?:ext|lib)-[^/]+)$}i'; + const PLATFORM_PACKAGE_REGEX = '{^(?:php(?:-64bit|-ipv6|-zts|-debug)?|hhvm|(?:ext|lib)-[^/ ]+)$}i'; private $versionParser; From 621a9d845cd5b571146298214ad27d5fff6cc670 Mon Sep 17 00:00:00 2001 From: Jean Baptiste Noblot Date: Fri, 19 Jan 2018 10:28:05 +0100 Subject: [PATCH 2/6] Add 'git-bitbucket' in RepositoryFactory Add 'git-bitbucket' and 'hg-bitbucket' in RepositoryFactory help to call good driver in vcs Cause if you config your repository type with 'git'. the GitDriver is instantiate and not GitBitbucketDriver Fix #5389 --- src/Composer/Repository/RepositoryFactory.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Composer/Repository/RepositoryFactory.php b/src/Composer/Repository/RepositoryFactory.php index 5e38f961a..ca479a7fd 100644 --- a/src/Composer/Repository/RepositoryFactory.php +++ b/src/Composer/Repository/RepositoryFactory.php @@ -119,12 +119,14 @@ class RepositoryFactory $rm->setRepositoryClass('package', 'Composer\Repository\PackageRepository'); $rm->setRepositoryClass('pear', 'Composer\Repository\PearRepository'); $rm->setRepositoryClass('git', 'Composer\Repository\VcsRepository'); + $rm->setRepositoryClass('git-bitbucket', 'Composer\Repository\VcsRepository'); $rm->setRepositoryClass('github', 'Composer\Repository\VcsRepository'); $rm->setRepositoryClass('gitlab', 'Composer\Repository\VcsRepository'); $rm->setRepositoryClass('svn', 'Composer\Repository\VcsRepository'); $rm->setRepositoryClass('fossil', 'Composer\Repository\VcsRepository'); $rm->setRepositoryClass('perforce', 'Composer\Repository\VcsRepository'); $rm->setRepositoryClass('hg', 'Composer\Repository\VcsRepository'); + $rm->setRepositoryClass('hg-bitbucket', 'Composer\Repository\VcsRepository'); $rm->setRepositoryClass('artifact', 'Composer\Repository\ArtifactRepository'); $rm->setRepositoryClass('path', 'Composer\Repository\PathRepository'); From 595cf4432c42a0c98042866ff21107ea90b2c523 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Date: Fri, 19 Jan 2018 10:51:32 +0100 Subject: [PATCH 3/6] Fix Test RepositoryFactory --- tests/Composer/Test/Repository/RepositoryFactoryTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/Composer/Test/Repository/RepositoryFactoryTest.php b/tests/Composer/Test/Repository/RepositoryFactoryTest.php index 6611abbb6..8ce66cfd5 100644 --- a/tests/Composer/Test/Repository/RepositoryFactoryTest.php +++ b/tests/Composer/Test/Repository/RepositoryFactoryTest.php @@ -34,12 +34,14 @@ class RepositoryFactoryTest extends TestCase 'package', 'pear', 'git', + 'git-bitbucket', 'github', 'gitlab', 'svn', 'fossil', 'perforce', 'hg', + 'hg-bitbucket', 'artifact', 'path', ), array_keys($repositoryClasses)); From f28feedf58ea5defbacfbcc9e03b06b97adfd068 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 22 Jan 2018 14:09:36 +0100 Subject: [PATCH 4/6] Update list of explicit VCS repo types, refs #7023 --- doc/05-repositories.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/05-repositories.md b/doc/05-repositories.md index 99ba5f36a..c28f34141 100644 --- a/doc/05-repositories.md +++ b/doc/05-repositories.md @@ -284,8 +284,9 @@ VCS repository provides `dist`s for them that fetch the packages as zips. * **BitBucket:** [bitbucket.org](https://bitbucket.org) (Git and Mercurial) The VCS driver to be used is detected automatically based on the URL. However, -should you need to specify one for whatever reason, you can use `fossil`, `git`, -`svn` or `hg` as the repository type instead of `vcs`. +should you need to specify one for whatever reason, you can use `git-bitbucket`, +`hg-bitbucket`, `github`, `gitlab`, `perforce`, `fossil`, `git`, `svn` or `hg` +as the repository type instead of `vcs`. If you set the `no-api` key to `true` on a github repository it will clone the repository as it would with any other git repository instead of using the From 6a7e9322333c72a629bef9a86b9b889bcf72e3e5 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Tue, 16 Jan 2018 15:13:36 +0100 Subject: [PATCH 5/6] Mention that also a antivirus software might corrupt file contents --- src/Composer/Repository/ComposerRepository.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Composer/Repository/ComposerRepository.php b/src/Composer/Repository/ComposerRepository.php index 2f0d19db9..60ab0dfbd 100644 --- a/src/Composer/Repository/ComposerRepository.php +++ b/src/Composer/Repository/ComposerRepository.php @@ -677,7 +677,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito } // TODO use scarier wording once we know for sure it doesn't do false positives anymore - throw new RepositorySecurityException('The contents of '.$filename.' do not match its signature. This could indicate a man-in-the-middle attack. Try running composer again and report this if you think it is a mistake.'); + throw new RepositorySecurityException('The contents of '.$filename.' do not match its signature. This could indicate a man-in-the-middle attack or e.g. antivirus software corrupting files. Try running composer again and report this if you think it is a mistake.'); } $data = JsonFile::parseJson($json, $filename); From a5e35b9e8939e116b0bcbd677179d26bc490e6a1 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 22 Jan 2018 15:17:30 +0100 Subject: [PATCH 6/6] Add --remove-vcs flag to create-project command to allow removing user prompts, fixes #7002 --- src/Composer/Command/CreateProjectCommand.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Composer/Command/CreateProjectCommand.php b/src/Composer/Command/CreateProjectCommand.php index 16960ac64..b1e711f3a 100644 --- a/src/Composer/Command/CreateProjectCommand.php +++ b/src/Composer/Command/CreateProjectCommand.php @@ -75,7 +75,8 @@ class CreateProjectCommand extends BaseCommand new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Whether to prevent execution of all defined scripts in the root package.'), new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'), new InputOption('no-secure-http', null, InputOption::VALUE_NONE, 'Disable the secure-http config option temporarily while installing the root package. Use at your own risk. Using this flag is a bad idea.'), - new InputOption('keep-vcs', null, InputOption::VALUE_NONE, 'Whether to prevent deletion vcs folder.'), + new InputOption('keep-vcs', null, InputOption::VALUE_NONE, 'Whether to prevent deleting the vcs folder.'), + new InputOption('remove-vcs', null, InputOption::VALUE_NONE, 'Whether to force deletion of the vcs folder without prompting.'), new InputOption('no-install', null, InputOption::VALUE_NONE, 'Whether to skip installation of the package dependencies.'), new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore platform requirements (php & ext- packages).'), )) @@ -140,11 +141,12 @@ EOT $input->getOption('no-progress'), $input->getOption('no-install'), $input->getOption('ignore-platform-reqs'), - !$input->getOption('no-secure-http') + !$input->getOption('no-secure-http'), + $input->getOption('remove-vcs') ); } - public function installProject(IOInterface $io, Config $config, InputInterface $input, $packageName, $directory = null, $packageVersion = null, $stability = 'stable', $preferSource = false, $preferDist = false, $installDevPackages = false, $repository = null, $disablePlugins = false, $noScripts = false, $keepVcs = false, $noProgress = false, $noInstall = false, $ignorePlatformReqs = false, $secureHttp = true) + public function installProject(IOInterface $io, Config $config, InputInterface $input, $packageName, $directory = null, $packageVersion = null, $stability = 'stable', $preferSource = false, $preferDist = false, $installDevPackages = false, $repository = null, $disablePlugins = false, $noScripts = false, $keepVcs = false, $noProgress = false, $noInstall = false, $ignorePlatformReqs = false, $secureHttp = true, $removeVcs = false) { $oldCwd = getcwd(); @@ -195,9 +197,12 @@ EOT } $hasVcs = $installedFromVcs; - if (!$keepVcs && $installedFromVcs + if ( + !$keepVcs + && $installedFromVcs && ( - !$io->isInteractive() + $removeVcs + || !$io->isInteractive() || $io->askConfirmation('Do you want to remove the existing VCS (.git, .svn..) history? [Y,n]? ', true) ) ) {