1
0
Fork 0

Merge branch '1.6'

pull/7096/merge
Jordi Boggiano 2018-04-12 17:01:00 +02:00
commit 2bd34c0534
18 changed files with 163 additions and 130 deletions

118
composer.lock generated
View File

@ -8,16 +8,16 @@
"packages": [ "packages": [
{ {
"name": "composer/ca-bundle", "name": "composer/ca-bundle",
"version": "1.1.0", "version": "1.1.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/composer/ca-bundle.git", "url": "https://github.com/composer/ca-bundle.git",
"reference": "943b2c4fcad1ef178d16a713c2468bf7e579c288" "reference": "d2c0a83b7533d6912e8d516756ebd34f893e9169"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/composer/ca-bundle/zipball/943b2c4fcad1ef178d16a713c2468bf7e579c288", "url": "https://api.github.com/repos/composer/ca-bundle/zipball/d2c0a83b7533d6912e8d516756ebd34f893e9169",
"reference": "943b2c4fcad1ef178d16a713c2468bf7e579c288", "reference": "d2c0a83b7533d6912e8d516756ebd34f893e9169",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -26,7 +26,7 @@
"php": "^5.3.2 || ^7.0" "php": "^5.3.2 || ^7.0"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "^4.8.35", "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5",
"psr/log": "^1.0", "psr/log": "^1.0",
"symfony/process": "^2.5 || ^3.0 || ^4.0" "symfony/process": "^2.5 || ^3.0 || ^4.0"
}, },
@ -60,7 +60,7 @@
"ssl", "ssl",
"tls" "tls"
], ],
"time": "2017-11-29T09:37:33+00:00" "time": "2018-03-29T19:57:20+00:00"
}, },
{ {
"name": "composer/semver", "name": "composer/semver",
@ -187,16 +187,16 @@
}, },
{ {
"name": "justinrainbow/json-schema", "name": "justinrainbow/json-schema",
"version": "5.2.6", "version": "5.2.7",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/justinrainbow/json-schema.git", "url": "https://github.com/justinrainbow/json-schema.git",
"reference": "d283e11b6e14c6f4664cf080415c4341293e5bbd" "reference": "8560d4314577199ba51bf2032f02cd1315587c23"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/justinrainbow/json-schema/zipball/d283e11b6e14c6f4664cf080415c4341293e5bbd", "url": "https://api.github.com/repos/justinrainbow/json-schema/zipball/8560d4314577199ba51bf2032f02cd1315587c23",
"reference": "d283e11b6e14c6f4664cf080415c4341293e5bbd", "reference": "8560d4314577199ba51bf2032f02cd1315587c23",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -205,7 +205,7 @@
"require-dev": { "require-dev": {
"friendsofphp/php-cs-fixer": "^2.1", "friendsofphp/php-cs-fixer": "^2.1",
"json-schema/json-schema-test-suite": "1.2.0", "json-schema/json-schema-test-suite": "1.2.0",
"phpunit/phpunit": "^4.8.22" "phpunit/phpunit": "^4.8.35"
}, },
"bin": [ "bin": [
"bin/validate-json" "bin/validate-json"
@ -249,7 +249,7 @@
"json", "json",
"schema" "schema"
], ],
"time": "2017-10-21T13:15:38+00:00" "time": "2018-02-14T22:26:30+00:00"
}, },
{ {
"name": "psr/log", "name": "psr/log",
@ -348,16 +348,16 @@
}, },
{ {
"name": "seld/jsonlint", "name": "seld/jsonlint",
"version": "1.7.0", "version": "1.7.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/Seldaek/jsonlint.git", "url": "https://github.com/Seldaek/jsonlint.git",
"reference": "9b355654ea99460397b89c132b5c1087b6bf4473" "reference": "d15f59a67ff805a44c50ea0516d2341740f81a38"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/Seldaek/jsonlint/zipball/9b355654ea99460397b89c132b5c1087b6bf4473", "url": "https://api.github.com/repos/Seldaek/jsonlint/zipball/d15f59a67ff805a44c50ea0516d2341740f81a38",
"reference": "9b355654ea99460397b89c132b5c1087b6bf4473", "reference": "d15f59a67ff805a44c50ea0516d2341740f81a38",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -393,7 +393,7 @@
"parser", "parser",
"validator" "validator"
], ],
"time": "2018-01-03T12:13:57+00:00" "time": "2018-01-24T12:46:19+00:00"
}, },
{ {
"name": "seld/phar-utils", "name": "seld/phar-utils",
@ -441,16 +441,16 @@
}, },
{ {
"name": "symfony/console", "name": "symfony/console",
"version": "v2.8.32", "version": "v2.8.38",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/console.git", "url": "https://github.com/symfony/console.git",
"reference": "46270f1ca44f08ebc134ce120fd2c2baf5fd63de" "reference": "7f78892d900c72a40acd1fe793c856ef0c110f26"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/46270f1ca44f08ebc134ce120fd2c2baf5fd63de", "url": "https://api.github.com/repos/symfony/console/zipball/7f78892d900c72a40acd1fe793c856ef0c110f26",
"reference": "46270f1ca44f08ebc134ce120fd2c2baf5fd63de", "reference": "7f78892d900c72a40acd1fe793c856ef0c110f26",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -498,20 +498,20 @@
], ],
"description": "Symfony Console Component", "description": "Symfony Console Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2017-11-29T09:33:18+00:00" "time": "2018-04-03T05:20:27+00:00"
}, },
{ {
"name": "symfony/debug", "name": "symfony/debug",
"version": "v2.8.32", "version": "v2.8.38",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/debug.git", "url": "https://github.com/symfony/debug.git",
"reference": "e72a0340dc2e273b3c4398d8eef9157ba51d8b95" "reference": "4486d2be5e068b51fece4c8551c14e709f573c8d"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/debug/zipball/e72a0340dc2e273b3c4398d8eef9157ba51d8b95", "url": "https://api.github.com/repos/symfony/debug/zipball/4486d2be5e068b51fece4c8551c14e709f573c8d",
"reference": "e72a0340dc2e273b3c4398d8eef9157ba51d8b95", "reference": "4486d2be5e068b51fece4c8551c14e709f573c8d",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -555,20 +555,20 @@
], ],
"description": "Symfony Debug Component", "description": "Symfony Debug Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2017-11-19T19:05:05+00:00" "time": "2018-04-03T05:20:27+00:00"
}, },
{ {
"name": "symfony/filesystem", "name": "symfony/filesystem",
"version": "v2.8.32", "version": "v2.8.38",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/filesystem.git", "url": "https://github.com/symfony/filesystem.git",
"reference": "15ceb6736a9eebd0d99f9e05a62296ab6ce1cf2b" "reference": "125403a59e4cb4e3ebf46d0162fabcde613d2b97"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/filesystem/zipball/15ceb6736a9eebd0d99f9e05a62296ab6ce1cf2b", "url": "https://api.github.com/repos/symfony/filesystem/zipball/125403a59e4cb4e3ebf46d0162fabcde613d2b97",
"reference": "15ceb6736a9eebd0d99f9e05a62296ab6ce1cf2b", "reference": "125403a59e4cb4e3ebf46d0162fabcde613d2b97",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -604,20 +604,20 @@
], ],
"description": "Symfony Filesystem Component", "description": "Symfony Filesystem Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2017-11-19T18:39:05+00:00" "time": "2018-02-19T16:23:47+00:00"
}, },
{ {
"name": "symfony/finder", "name": "symfony/finder",
"version": "v2.8.32", "version": "v2.8.38",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/finder.git", "url": "https://github.com/symfony/finder.git",
"reference": "efeceae6a05a9b2fcb3391333f1d4a828ff44ab8" "reference": "423746fc18ccf31f9abec43e4f078bb6e024b2d5"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/finder/zipball/efeceae6a05a9b2fcb3391333f1d4a828ff44ab8", "url": "https://api.github.com/repos/symfony/finder/zipball/423746fc18ccf31f9abec43e4f078bb6e024b2d5",
"reference": "efeceae6a05a9b2fcb3391333f1d4a828ff44ab8", "reference": "423746fc18ccf31f9abec43e4f078bb6e024b2d5",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -653,20 +653,20 @@
], ],
"description": "Symfony Finder Component", "description": "Symfony Finder Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2017-11-05T15:25:56+00:00" "time": "2018-04-04T13:38:31+00:00"
}, },
{ {
"name": "symfony/polyfill-mbstring", "name": "symfony/polyfill-mbstring",
"version": "v1.6.0", "version": "v1.7.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git", "url": "https://github.com/symfony/polyfill-mbstring.git",
"reference": "2ec8b39c38cb16674bbf3fea2b6ce5bf117e1296" "reference": "78be803ce01e55d3491c1397cf1c64beb9c1b63b"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/2ec8b39c38cb16674bbf3fea2b6ce5bf117e1296", "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/78be803ce01e55d3491c1397cf1c64beb9c1b63b",
"reference": "2ec8b39c38cb16674bbf3fea2b6ce5bf117e1296", "reference": "78be803ce01e55d3491c1397cf1c64beb9c1b63b",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -678,7 +678,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "1.6-dev" "dev-master": "1.7-dev"
} }
}, },
"autoload": { "autoload": {
@ -712,20 +712,20 @@
"portable", "portable",
"shim" "shim"
], ],
"time": "2017-10-11T12:05:26+00:00" "time": "2018-01-30T19:27:44+00:00"
}, },
{ {
"name": "symfony/process", "name": "symfony/process",
"version": "v2.8.32", "version": "v2.8.38",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/process.git", "url": "https://github.com/symfony/process.git",
"reference": "d25449e031f600807949aab7cadbf267712f4eee" "reference": "ee2c91470ff262b1a00aec27875d38594aa87629"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/process/zipball/d25449e031f600807949aab7cadbf267712f4eee", "url": "https://api.github.com/repos/symfony/process/zipball/ee2c91470ff262b1a00aec27875d38594aa87629",
"reference": "d25449e031f600807949aab7cadbf267712f4eee", "reference": "ee2c91470ff262b1a00aec27875d38594aa87629",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -761,7 +761,7 @@
], ],
"description": "Symfony Process Component", "description": "Symfony Process Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2017-11-05T15:25:56+00:00" "time": "2018-04-03T05:20:27+00:00"
} }
], ],
"packages-dev": [ "packages-dev": [
@ -870,16 +870,16 @@
}, },
{ {
"name": "phpspec/prophecy", "name": "phpspec/prophecy",
"version": "1.7.3", "version": "1.7.5",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/phpspec/prophecy.git", "url": "https://github.com/phpspec/prophecy.git",
"reference": "e4ed002c67da8eceb0eb8ddb8b3847bb53c5c2bf" "reference": "dfd6be44111a7c41c2e884a336cc4f461b3b2401"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/e4ed002c67da8eceb0eb8ddb8b3847bb53c5c2bf", "url": "https://api.github.com/repos/phpspec/prophecy/zipball/dfd6be44111a7c41c2e884a336cc4f461b3b2401",
"reference": "e4ed002c67da8eceb0eb8ddb8b3847bb53c5c2bf", "reference": "dfd6be44111a7c41c2e884a336cc4f461b3b2401",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -891,7 +891,7 @@
}, },
"require-dev": { "require-dev": {
"phpspec/phpspec": "^2.5|^3.2", "phpspec/phpspec": "^2.5|^3.2",
"phpunit/phpunit": "^4.8.35 || ^5.7" "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
@ -929,7 +929,7 @@
"spy", "spy",
"stub" "stub"
], ],
"time": "2017-11-24T13:59:53+00:00" "time": "2018-02-19T10:16:54+00:00"
}, },
{ {
"name": "phpunit/php-code-coverage", "name": "phpunit/php-code-coverage",
@ -1681,16 +1681,16 @@
}, },
{ {
"name": "symfony/yaml", "name": "symfony/yaml",
"version": "v2.8.32", "version": "v2.8.38",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/yaml.git", "url": "https://github.com/symfony/yaml.git",
"reference": "968ef42161e4bc04200119da473077f9e7015128" "reference": "be720fcfae4614df204190d57795351059946a77"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/yaml/zipball/968ef42161e4bc04200119da473077f9e7015128", "url": "https://api.github.com/repos/symfony/yaml/zipball/be720fcfae4614df204190d57795351059946a77",
"reference": "968ef42161e4bc04200119da473077f9e7015128", "reference": "be720fcfae4614df204190d57795351059946a77",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1726,7 +1726,7 @@
], ],
"description": "Symfony Yaml Component", "description": "Symfony Yaml Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2017-11-29T09:33:18+00:00" "time": "2018-01-03T07:36:31+00:00"
} }
], ],
"aliases": [], "aliases": [],

View File

@ -89,7 +89,7 @@ class BaseDependencyCommand extends BaseCommand
); );
// Find packages that are or provide the requested package first // Find packages that are or provide the requested package first
$packages = $pool->whatProvides($needle); $packages = $pool->whatProvides(strtolower($needle));
if (empty($packages)) { if (empty($packages)) {
throw new \InvalidArgumentException(sprintf('Could not find package "%s" in your project', $needle)); throw new \InvalidArgumentException(sprintf('Could not find package "%s" in your project', $needle));
} }

View File

@ -319,11 +319,16 @@ EOT
$io->writeError(array('', 'Define your dependencies.', '')); $io->writeError(array('', 'Define your dependencies.', ''));
// prepare to resolve dependencies
$repos = $this->getRepos();
$preferredStability = $minimumStability ?: 'stable';
$phpVersion = $repos->findPackage('php', '*')->getPrettyVersion();
$question = 'Would you like to define your dependencies (require) interactively [<comment>yes</comment>]? '; $question = 'Would you like to define your dependencies (require) interactively [<comment>yes</comment>]? ';
$require = $input->getOption('require'); $require = $input->getOption('require');
$requirements = array(); $requirements = array();
if ($require || $io->askConfirmation($question, true)) { if ($require || $io->askConfirmation($question, true)) {
$requirements = $this->determineRequirements($input, $output, $require); $requirements = $this->determineRequirements($input, $output, $require, $phpVersion, $preferredStability);
} }
$input->setOption('require', $requirements); $input->setOption('require', $requirements);
@ -331,7 +336,7 @@ EOT
$requireDev = $input->getOption('require-dev'); $requireDev = $input->getOption('require-dev');
$devRequirements = array(); $devRequirements = array();
if ($requireDev || $io->askConfirmation($question, true)) { if ($requireDev || $io->askConfirmation($question, true)) {
$devRequirements = $this->determineRequirements($input, $output, $requireDev); $devRequirements = $this->determineRequirements($input, $output, $requireDev, $phpVersion, $preferredStability);
} }
$input->setOption('require-dev', $devRequirements); $input->setOption('require-dev', $devRequirements);
} }

View File

@ -114,10 +114,14 @@ EOT
$io->writeError('<info>scripts:</info>'); $io->writeError('<info>scripts:</info>');
$table = array(); $table = array();
foreach ($scripts as $name => $script) { foreach ($scripts as $name => $script) {
$cmd = $this->getApplication()->find($name);
$description = ''; $description = '';
if ($cmd instanceof ScriptAliasCommand) { try {
$description = $cmd->getDescription(); $cmd = $this->getApplication()->find($name);
if ($cmd instanceof ScriptAliasCommand) {
$description = $cmd->getDescription();
}
} catch (\Symfony\Component\Console\Exception\CommandNotFoundException $e) {
// ignore scripts that have no command associated, like native Composer script listeners
} }
$table[] = array(' '.$name, $description); $table[] = array(' '.$name, $description);
} }

View File

@ -40,7 +40,7 @@ class StatusCommand extends BaseCommand
{ {
$this $this
->setName('status') ->setName('status')
->setDescription('Shows a list of locally modified packages.') ->setDescription('Shows a list of locally modified packages, for packages installed from source.')
->setDefinition(array( ->setDefinition(array(
new InputOption('verbose', 'v|vv|vvv', InputOption::VALUE_NONE, 'Show modified files for each directory that contains changes.'), new InputOption('verbose', 'v|vv|vvv', InputOption::VALUE_NONE, 'Show modified files for each directory that contains changes.'),
)) ))

View File

@ -87,7 +87,7 @@ class FossilDownloader extends VcsDownloader
*/ */
protected function getCommitLogs($fromReference, $toReference, $path) protected function getCommitLogs($fromReference, $toReference, $path)
{ {
$command = sprintf('fossil timeline -t ci -W 0 -n 0 before %s', $toReference); $command = sprintf('fossil timeline -t ci -W 0 -n 0 before %s', ProcessExecutor::escape($toReference));
if (0 !== $this->process->execute($command, $output, realpath($path))) { if (0 !== $this->process->execute($command, $output, realpath($path))) {
throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput()); throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());

View File

@ -423,7 +423,7 @@ class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
protected function getCommitLogs($fromReference, $toReference, $path) protected function getCommitLogs($fromReference, $toReference, $path)
{ {
$path = $this->normalizePath($path); $path = $this->normalizePath($path);
$command = sprintf('git log %s..%s --pretty=format:"%%h - %%an: %%s"', $fromReference, $toReference); $command = sprintf('git log %s..%s --pretty=format:"%%h - %%an: %%s"', ProcessExecutor::escape($fromReference), ProcessExecutor::escape($toReference));
if (0 !== $this->process->execute($command, $output, $path)) { if (0 !== $this->process->execute($command, $output, $path)) {
throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput()); throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());

View File

@ -82,7 +82,7 @@ class HgDownloader extends VcsDownloader
*/ */
protected function getCommitLogs($fromReference, $toReference, $path) protected function getCommitLogs($fromReference, $toReference, $path)
{ {
$command = sprintf('hg log -r %s:%s --style compact', $fromReference, $toReference); $command = sprintf('hg log -r %s:%s --style compact', ProcessExecutor::escape($fromReference), ProcessExecutor::escape($toReference));
if (0 !== $this->process->execute($command, $output, realpath($path))) { if (0 !== $this->process->execute($command, $output, realpath($path))) {
throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput()); throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());

View File

@ -57,11 +57,10 @@ class SvnDownloader extends VcsDownloader
throw new \RuntimeException('The .svn directory is missing from '.$path.', see https://getcomposer.org/commit-deps for more information'); throw new \RuntimeException('The .svn directory is missing from '.$path.', see https://getcomposer.org/commit-deps for more information');
} }
$util = new SvnUtil($url, $this->io, $this->config);
$flags = ""; $flags = "";
if (0 === $this->process->execute('svn --version', $output)) { if (version_compare($util->binaryVersion(), '1.7.0', '>=')) {
if (preg_match('{(\d+(?:\.\d+)+)}', $output, $match) && version_compare($match[1], '1.7.0', '>=')) { $flags .= ' --ignore-ancestry';
$flags .= ' --ignore-ancestry';
}
} }
$this->io->writeError(" Checking out " . $ref); $this->io->writeError(" Checking out " . $ref);
@ -193,7 +192,7 @@ class SvnDownloader extends VcsDownloader
$fromRevision = preg_replace('{.*@(\d+)$}', '$1', $fromReference); $fromRevision = preg_replace('{.*@(\d+)$}', '$1', $fromReference);
$toRevision = preg_replace('{.*@(\d+)$}', '$1', $toReference); $toRevision = preg_replace('{.*@(\d+)$}', '$1', $toReference);
$command = sprintf('svn log -r%s:%s --incremental', $fromRevision, $toRevision); $command = sprintf('svn log -r%s:%s --incremental', ProcessExecutor::escape($fromRevision), ProcessExecutor::escape($toRevision));
$util = new SvnUtil($baseUrl, $this->io, $this->config); $util = new SvnUtil($baseUrl, $this->io, $this->config);
$util->setCacheCredentials($this->cacheCredentials); $util->setCacheCredentials($this->cacheCredentials);

View File

@ -291,6 +291,10 @@ class ConsoleIO extends BaseIO
$result = $helper->ask($this->input, $this->getErrorOutput(), $question); $result = $helper->ask($this->input, $this->getErrorOutput(), $question);
if (!is_array($result)) {
return (string) array_search($result, $choices, true);
}
$results = array(); $results = array();
foreach ($choices as $index => $choice) { foreach ($choices as $index => $choice) {
if (in_array($choice, $result, true)) { if (in_array($choice, $result, true)) {

View File

@ -1184,9 +1184,9 @@ class Installer
$package->setSourceReference($sourceReference); $package->setSourceReference($sourceReference);
} }
// only update dist url for github/bitbucket dists as they use a combination of dist url + dist reference to install // only update dist url for github/bitbucket/gitlab dists as they use a combination of dist url + dist reference to install
// but for other urls this is ambiguous and could result in bad outcomes // but for other urls this is ambiguous and could result in bad outcomes
if (preg_match('{^https?://(?:(?:www\.)?bitbucket\.org|(api\.)?github\.com)/}i', $distUrl)) { if (preg_match('{^https?://(?:(?:www\.)?bitbucket\.org|(api\.)?github\.com|(?:www\.)?gitlab\.com)/}i', $distUrl)) {
$package->setDistUrl($distUrl); $package->setDistUrl($distUrl);
$this->updateInstallReferences($package, $sourceReference); $this->updateInstallReferences($package, $sourceReference);
} }
@ -1204,9 +1204,9 @@ class Installer
$package->setSourceReference($reference); $package->setSourceReference($reference);
if (preg_match('{^https?://(?:(?:www\.)?bitbucket\.org|(api\.)?github\.com)/}i', $package->getDistUrl())) { if (preg_match('{^https?://(?:(?:www\.)?bitbucket\.org|(api\.)?github\.com|(?:www\.)?gitlab\.com)/}i', $package->getDistUrl())) {
$package->setDistReference($reference); $package->setDistReference($reference);
$package->setDistUrl(preg_replace('{(?<=/)[a-f0-9]{40}(?=/|$)}i', $reference, $package->getDistUrl())); $package->setDistUrl(preg_replace('{(?<=/|sha=)[a-f0-9]{40}(?=/|$)}i', $reference, $package->getDistUrl()));
} elseif ($package->getDistReference()) { // update the dist reference if there was one, but if none was provided ignore it } elseif ($package->getDistReference()) { // update the dist reference if there was one, but if none was provided ignore it
$package->setDistReference($reference); $package->setDistReference($reference);
} }

View File

@ -184,7 +184,7 @@ class VersionGuesser
$isFeatureBranch = 0 === strpos($version, 'dev-'); $isFeatureBranch = 0 === strpos($version, 'dev-');
if ('9999999-dev' === $version) { if ('9999999-dev' === $version) {
$version = 'dev-' . $branch; return array('version' => $version, 'commit' => null, 'pretty_version' => 'dev-'.$branch);
} }
if (!$isFeatureBranch) { if (!$isFeatureBranch) {
@ -240,9 +240,6 @@ class VersionGuesser
$length = strlen($output); $length = strlen($output);
$version = $this->versionParser->normalizeBranch($candidate); $version = $this->versionParser->normalizeBranch($candidate);
$prettyVersion = 'dev-' . $match[1]; $prettyVersion = 'dev-' . $match[1];
if ('9999999-dev' === $version) {
$version = $prettyVersion;
}
} }
} }
} }
@ -260,10 +257,6 @@ class VersionGuesser
$branch = trim($output); $branch = trim($output);
$version = $this->versionParser->normalizeBranch($branch); $version = $this->versionParser->normalizeBranch($branch);
$prettyVersion = 'dev-' . $branch; $prettyVersion = 'dev-' . $branch;
if ('9999999-dev' === $version) {
$version = $prettyVersion;
}
} }
// try to fetch current version from fossil tags // try to fetch current version from fossil tags
@ -295,9 +288,6 @@ class VersionGuesser
// we are in a branches path // we are in a branches path
$version = $this->versionParser->normalizeBranch($matches[3]); $version = $this->versionParser->normalizeBranch($matches[3]);
$prettyVersion = 'dev-' . $matches[3]; $prettyVersion = 'dev-' . $matches[3];
if ('9999999-dev' === $version) {
$version = $prettyVersion;
}
return array('version' => $version, 'commit' => '', 'pretty_version' => $prettyVersion); return array('version' => $version, 'commit' => '', 'pretty_version' => $prettyVersion);
} }

View File

@ -39,7 +39,7 @@ abstract class BaseRepository implements RepositoryInterface
*/ */
public function getDependents($needle, $constraint = null, $invert = false, $recurse = true, $packagesFound = null) public function getDependents($needle, $constraint = null, $invert = false, $recurse = true, $packagesFound = null)
{ {
$needles = (array) $needle; $needles = array_map('strtolower', (array) $needle);
$results = array(); $results = array();
// initialize the array with the needles before any recursion occurs // initialize the array with the needles before any recursion occurs

View File

@ -155,7 +155,7 @@ class PathRepository extends ArrayRepository implements ConfigurableRepositoryIn
if (!isset($package['version'])) { if (!isset($package['version'])) {
$versionData = $this->versionGuesser->guessVersion($package, $path); $versionData = $this->versionGuesser->guessVersion($package, $path);
$package['version'] = $versionData['version'] ?: 'dev-master'; $package['version'] = $versionData['pretty_version'] ?: 'dev-master';
} }
$output = ''; $output = '';

View File

@ -353,7 +353,7 @@ class SvnDriver extends VcsDriver
try { try {
return $this->util->execute($command, $url); return $this->util->execute($command, $url);
} catch (\RuntimeException $e) { } catch (\RuntimeException $e) {
if (0 !== $this->process->execute('svn --version', $ignoredOutput)) { if (null === $this->util->binaryVersion()) {
throw new \RuntimeException('Failed to load '.$this->url.', svn was not found, check that it is installed and in your PATH env.' . "\n\n" . $this->process->getErrorOutput()); throw new \RuntimeException('Failed to load '.$this->url.', svn was not found, check that it is installed and in your PATH env.' . "\n\n" . $this->process->getErrorOutput());
} }

View File

@ -175,6 +175,24 @@ class RemoteFilesystem
return $value; return $value;
} }
/**
* @param array $headers array of returned headers like from getLastHeaders()
* @return string|null
*/
public function findStatusMessage(array $headers)
{
$value = null;
foreach ($headers as $header) {
if (preg_match('{^HTTP/\S+ \d+}i', $header)) {
// In case of redirects, http_response_headers contains the headers of all responses
// so we can not return directly and need to keep iterating
$value = $header;
}
}
return $value;
}
/** /**
* Get file content or copy action. * Get file content or copy action.
* *
@ -299,6 +317,20 @@ class RemoteFilesystem
try { try {
list($http_response_header, $result) = $this->getRemoteContents($originUrl, $fileUrl, $ctx); list($http_response_header, $result) = $this->getRemoteContents($originUrl, $fileUrl, $ctx);
if (!empty($http_response_header[0])) {
$statusCode = $this->findStatusCode($http_response_header);
if (in_array($statusCode, array(401, 403)) && $this->retryAuthFailure) {
$warning = null;
if ($this->findHeaderValue($http_response_header, 'content-type') === 'application/json') {
$data = json_decode($result, true);
if (!empty($data['warning'])) {
$warning = $data['warning'];
}
}
$this->promptAuthAndRetry($statusCode, $this->findStatusMessage($http_response_header), $warning);
}
}
$contentLength = !empty($http_response_header[0]) ? $this->findHeaderValue($http_response_header, 'content-length') : null; $contentLength = !empty($http_response_header[0]) ? $this->findHeaderValue($http_response_header, 'content-length') : null;
if ($contentLength && Platform::strlen($result) < $contentLength) { if ($contentLength && Platform::strlen($result) < $contentLength) {
// alas, this is not possible via the stream callback because STREAM_NOTIFY_COMPLETED is documented, but not implemented anywhere in PHP // alas, this is not possible via the stream callback because STREAM_NOTIFY_COMPLETED is documented, but not implemented anywhere in PHP
@ -574,29 +606,6 @@ class RemoteFilesystem
// but you do not send an appropriate certificate // but you do not send an appropriate certificate
throw new TransportException("The '" . $this->fileUrl . "' URL could not be accessed: " . $message, $messageCode); throw new TransportException("The '" . $this->fileUrl . "' URL could not be accessed: " . $message, $messageCode);
} }
// intentional fallthrough to the next case as the notificationCode
// isn't always consistent and we should inspect the messageCode for 401s
case STREAM_NOTIFY_AUTH_REQUIRED:
if (401 === $messageCode) {
// Bail if the caller is going to handle authentication failures itself.
if (!$this->retryAuthFailure) {
break;
}
$this->promptAuthAndRetry($messageCode);
}
break;
case STREAM_NOTIFY_AUTH_RESULT:
if (403 === $messageCode) {
// Bail if the caller is going to handle authentication failures itself.
if (!$this->retryAuthFailure) {
break;
}
$this->promptAuthAndRetry($messageCode, $message);
}
break; break;
case STREAM_NOTIFY_FILE_SIZE_IS: case STREAM_NOTIFY_FILE_SIZE_IS:
@ -619,7 +628,7 @@ class RemoteFilesystem
} }
} }
protected function promptAuthAndRetry($httpStatus, $reason = null) protected function promptAuthAndRetry($httpStatus, $reason = null, $warning = null)
{ {
if ($this->config && in_array($this->originUrl, $this->config->get('github-domains'), true)) { if ($this->config && in_array($this->originUrl, $this->config->get('github-domains'), true)) {
$message = "\n".'Could not fetch '.$this->fileUrl.', please create a GitHub OAuth token '.($httpStatus === 404 ? 'to access private repos' : 'to go over the API rate limit'); $message = "\n".'Could not fetch '.$this->fileUrl.', please create a GitHub OAuth token '.($httpStatus === 404 ? 'to access private repos' : 'to go over the API rate limit');
@ -690,6 +699,9 @@ class RemoteFilesystem
} }
$this->io->overwriteError(''); $this->io->overwriteError('');
if ($warning) {
$this->io->writeError(' <warning>'.$warning.'</warning>');
}
$this->io->writeError(' Authentication required (<info>'.parse_url($this->fileUrl, PHP_URL_HOST).'</info>):'); $this->io->writeError(' Authentication required (<info>'.parse_url($this->fileUrl, PHP_URL_HOST).'</info>):');
$username = $this->io->ask(' Username: '); $username = $this->io->ask(' Username: ');
$password = $this->io->askAndHideAnswer(' Password: '); $password = $this->io->askAndHideAnswer(' Password: ');

View File

@ -63,6 +63,11 @@ class Svn
*/ */
protected $config; protected $config;
/**
* @var string|null
*/
static private $version;
/** /**
* @param string $url * @param string $url
* @param \Composer\IO\IOInterface $io * @param \Composer\IO\IOInterface $io
@ -102,9 +107,7 @@ class Svn
// Ensure we are allowed to use this URL by config // Ensure we are allowed to use this URL by config
$this->config->prohibitUrlByConfig($url, $this->io); $this->config->prohibitUrlByConfig($url, $this->io);
$svnCommand = $this->getCommand($command, $url, $path); return $this->executeWithAuthRetry($command, $cwd, $url, $path, $verbose);
return $this->executeWithAuthRetry($svnCommand, $cwd, $path, $verbose);
} }
/** /**
@ -121,18 +124,15 @@ class Svn
*/ */
public function executeLocal($command, $path, $cwd = null, $verbose = false) public function executeLocal($command, $path, $cwd = null, $verbose = false)
{ {
$svnCommand = sprintf('%s %s%s %s', // A local command has no remote url
$command, return $this->executeWithAuthRetry($command, $cwd, '', $path, $verbose);
'--non-interactive ',
$this->getCredentialString(),
ProcessExecutor::escape($path)
);
return $this->executeWithAuthRetry($svnCommand, $cwd, $path, $verbose);
} }
private function executeWithAuthRetry($command, $cwd, $path, $verbose) private function executeWithAuthRetry($svnCommand, $cwd, $url, $path, $verbose)
{ {
// Regenerate the command at each try, to use the newly user-provided credentials
$command = $this->getCommand($svnCommand, $url, $path);
$output = null; $output = null;
$io = $this->io; $io = $this->io;
$handler = function ($type, $buffer) use (&$output, $io, $verbose) { $handler = function ($type, $buffer) use (&$output, $io, $verbose) {
@ -170,7 +170,7 @@ class Svn
// try to authenticate if maximum quantity of tries not reached // try to authenticate if maximum quantity of tries not reached
if ($this->qtyAuthTries++ < self::MAX_QTY_AUTH_TRIES) { if ($this->qtyAuthTries++ < self::MAX_QTY_AUTH_TRIES) {
// restart the process // restart the process
return $this->executeWithAuthRetry($command, $cwd, $path, $verbose); return $this->executeWithAuthRetry($svnCommand, $cwd, $url, $path, $verbose);
} }
throw new \RuntimeException( throw new \RuntimeException(
@ -359,4 +359,22 @@ class Svn
return $this->hasAuth = true; return $this->hasAuth = true;
} }
/**
* Returns the version of the svn binary contained in PATH
*
* @return string|null
*/
public function binaryVersion()
{
if (!self::$version) {
if (0 === $this->process->execute('svn --version', $output)) {
if (preg_match('{(\d+(?:\.\d+)+)}', $output, $match)) {
self::$version = $match[1];
}
}
}
return self::$version;
}
} }

View File

@ -89,7 +89,8 @@ class VersionGuesserTest extends TestCase
$guesser = new VersionGuesser($config, $executor, new VersionParser()); $guesser = new VersionGuesser($config, $executor, new VersionParser());
$versionArray = $guesser->guessVersion(array(), 'dummy/path'); $versionArray = $guesser->guessVersion(array(), 'dummy/path');
$this->assertEquals('dev-' . $branch, $versionArray['version']); $this->assertEquals("9999999-dev", $versionArray['version']);
$this->assertEquals("dev-".$branch, $versionArray['pretty_version']);
$this->assertEmpty($versionArray['commit']); $this->assertEmpty($versionArray['commit']);
} }