From 1336029b72d5e33826db030be5b499467195981a Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 12 Apr 2018 17:36:57 +0200 Subject: [PATCH 1/5] Fix type hints to match latest symfony, fixes #7199 --- src/Composer/IO/IOInterface.php | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Composer/IO/IOInterface.php b/src/Composer/IO/IOInterface.php index 75c86de20..5766ba479 100644 --- a/src/Composer/IO/IOInterface.php +++ b/src/Composer/IO/IOInterface.php @@ -103,8 +103,8 @@ interface IOInterface /** * Asks a question to the user. * - * @param string|array $question The question to ask - * @param string $default The default answer if none is given by the user + * @param string $question The question to ask + * @param string $default The default answer if none is given by the user * * @throws \RuntimeException If there is no data to read in the input stream * @return string The user answer @@ -116,8 +116,8 @@ interface IOInterface * * The question will be asked until the user answers by nothing, yes, or no. * - * @param string|array $question The question to ask - * @param bool $default The default answer if the user enters nothing + * @param string $question The question to ask + * @param bool $default The default answer if the user enters nothing * * @return bool true if the user has confirmed, false otherwise */ @@ -130,10 +130,10 @@ interface IOInterface * validated data when the data is valid and throw an exception * otherwise. * - * @param string|array $question The question to ask - * @param callable $validator A PHP callback - * @param null|int $attempts Max number of times to ask before giving up (default of null means infinite) - * @param mixed $default The default answer if none is given by the user + * @param string $question The question to ask + * @param callable $validator A PHP callback + * @param null|int $attempts Max number of times to ask before giving up (default of null means infinite) + * @param mixed $default The default answer if none is given by the user * * @throws \Exception When any of the validators return an error * @return mixed @@ -152,12 +152,12 @@ interface IOInterface /** * Asks the user to select a value. * - * @param string|array $question The question to ask - * @param array $choices List of choices to pick from - * @param bool|string $default The default answer if the user enters nothing - * @param bool|int $attempts Max number of times to ask before giving up (false by default, which means infinite) - * @param string $errorMessage Message which will be shown if invalid value from choice list would be picked - * @param bool $multiselect Select more than one value separated by comma + * @param string $question The question to ask + * @param array $choices List of choices to pick from + * @param bool|string $default The default answer if the user enters nothing + * @param bool|int $attempts Max number of times to ask before giving up (false by default, which means infinite) + * @param string $errorMessage Message which will be shown if invalid value from choice list would be picked + * @param bool $multiselect Select more than one value separated by comma * * @throws \InvalidArgumentException * @return int|string|array The selected value or values (the key of the choices array) From 9bee2ca28eea068f108ac4398fe82f12a8af6bc1 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Mon, 5 Mar 2018 09:45:48 +0100 Subject: [PATCH 2/5] make sure we only cache resources which contain a svn revision like we do in the VCS driver. Closes #7158 --- src/Composer/Repository/Vcs/SvnDriver.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Composer/Repository/Vcs/SvnDriver.php b/src/Composer/Repository/Vcs/SvnDriver.php index 1faba8195..b963f6856 100644 --- a/src/Composer/Repository/Vcs/SvnDriver.php +++ b/src/Composer/Repository/Vcs/SvnDriver.php @@ -115,19 +115,29 @@ class SvnDriver extends VcsDriver return null; } + /** + * {@inheritdoc} + */ + protected function shouldCache($identifier) + { + return $this->cache && preg_match('{@\d+$}', $identifier); + } + /** * {@inheritdoc} */ public function getComposerInformation($identifier) { if (!isset($this->infoCache[$identifier])) { - if ($res = $this->cache->read($identifier.'.json')) { + if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier.'.json')) { return $this->infoCache[$identifier] = JsonFile::parseJson($res); } $composer = $this->getBaseComposerInformation($identifier); - $this->cache->write($identifier.'.json', json_encode($composer)); + if ($this->shouldCache($identifier)) { + $this->cache->write($identifier.'.json', json_encode($composer)); + } $this->infoCache[$identifier] = $composer; } From 277f32d388b4a2d26aed199d04dff937cfb5de8c Mon Sep 17 00:00:00 2001 From: Filippo Tessarotto Date: Fri, 9 Feb 2018 09:03:28 +0100 Subject: [PATCH 3/5] Lock _readme: remove outdated hashtag link part, closes #7096 --- src/Composer/Package/Locker.php | 2 +- tests/Composer/Test/Package/LockerTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Composer/Package/Locker.php b/src/Composer/Package/Locker.php index fe2616cb4..7fbe536f2 100644 --- a/src/Composer/Package/Locker.php +++ b/src/Composer/Package/Locker.php @@ -289,7 +289,7 @@ class Locker { $lock = array( '_readme' => array('This file locks the dependencies of your project to a known state', - 'Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file', + 'Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies', 'This file is @gener'.'ated automatically', ), 'content-hash' => $this->contentHash, 'packages' => null, diff --git a/tests/Composer/Test/Package/LockerTest.php b/tests/Composer/Test/Package/LockerTest.php index a37e09907..b5692b009 100644 --- a/tests/Composer/Test/Package/LockerTest.php +++ b/tests/Composer/Test/Package/LockerTest.php @@ -133,7 +133,7 @@ class LockerTest extends TestCase ->method('write') ->with(array( '_readme' => array('This file locks the dependencies of your project to a known state', - 'Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file', + 'Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies', 'This file is @gener'.'ated automatically', ), 'content-hash' => $contentHash, 'packages' => array( From 89e138a593d1d23a862c9e6e51201026b90b7df9 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 12 Apr 2018 19:06:24 +0200 Subject: [PATCH 4/5] Add hint about .local/bin to docs, fixes #7132 --- doc/00-intro.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/00-intro.md b/doc/00-intro.md index e0a81b05b..2470f45fe 100644 --- a/doc/00-intro.md +++ b/doc/00-intro.md @@ -94,6 +94,10 @@ you can run this to move composer.phar to a directory that is in your path: mv composer.phar /usr/local/bin/composer ``` +If you like to install it only for your user and avoid requiring root permissions, +you can use `~/.local/bin` instead which is available by default on some +Linux distributions. + > **Note:** If the above fails due to permissions, you may need to run it again > with sudo. From af3783b5f40bae32a23e353eaf0a00c9b8ce82e2 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Mon, 5 Mar 2018 09:34:40 +0100 Subject: [PATCH 5/5] properly cache when a branch in a certain revision does not contain a composer.json this prevents requesting/trying to get the composer.json over and over again even if no commits happend Closes #7156 --- src/Composer/Repository/Vcs/SvnDriver.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Composer/Repository/Vcs/SvnDriver.php b/src/Composer/Repository/Vcs/SvnDriver.php index b963f6856..822510601 100644 --- a/src/Composer/Repository/Vcs/SvnDriver.php +++ b/src/Composer/Repository/Vcs/SvnDriver.php @@ -133,7 +133,16 @@ class SvnDriver extends VcsDriver return $this->infoCache[$identifier] = JsonFile::parseJson($res); } - $composer = $this->getBaseComposerInformation($identifier); + try { + $composer = $this->getBaseComposerInformation($identifier); + } catch(TransportException $e) { + $message = $e->getMessage(); + if (stripos($message, 'path not found') === false && stripos($message, 'svn: warning: W160013') === false) { + throw $e; + } + // remember a not-existent composer.json + $composer = ''; + } if ($this->shouldCache($identifier)) { $this->cache->write($identifier.'.json', json_encode($composer));