diff --git a/src/Composer/Command/BaseCommand.php b/src/Composer/Command/BaseCommand.php index 5198f06bf..901c7f35e 100644 --- a/src/Composer/Command/BaseCommand.php +++ b/src/Composer/Command/BaseCommand.php @@ -255,6 +255,11 @@ abstract class BaseCommand extends Command } } } + if (true == $input->hasOption('update-no-dev')) { + if (true !== $input->getOption('update-no-dev') && true == Platform::getEnv('COMPOSER_NO_DEV')) { + $input->setOption('update-no-dev', true); + } + } if (true === $input->hasOption('ignore-platform-reqs')) { if (!$input->getOption('ignore-platform-reqs') && (bool) Platform::getEnv('COMPOSER_IGNORE_PLATFORM_REQS')) { diff --git a/src/Composer/Repository/Vcs/GitHubDriver.php b/src/Composer/Repository/Vcs/GitHubDriver.php index d22b553ff..0e59f5239 100644 --- a/src/Composer/Repository/Vcs/GitHubDriver.php +++ b/src/Composer/Repository/Vcs/GitHubDriver.php @@ -59,7 +59,7 @@ class GitHubDriver extends VcsDriver */ public function initialize(): void { - if (!Preg::isMatch('#^(?:(?:https?|git)://([^/]+)/|git@([^:]+):/?)([^/]+)/(.+?)(?:\.git|/)?$#', $this->url, $match)) { + if (!Preg::isMatch('#^(?:(?:https?|git)://([^/]+)/|git@([^:]+):/?)([^/]+)/([^/]+?)(?:\.git|/)?$#', $this->url, $match)) { throw new \InvalidArgumentException(sprintf('The GitHub repository URL %s is invalid.', $this->url)); } @@ -397,7 +397,7 @@ class GitHubDriver extends VcsDriver */ public static function supports(IOInterface $io, Config $config, string $url, bool $deep = false): bool { - if (!Preg::isMatch('#^((?:https?|git)://([^/]+)/|git@([^:]+):/?)([^/]+)/(.+?)(?:\.git|/)?$#', $url, $matches)) { + if (!Preg::isMatch('#^((?:https?|git)://([^/]+)/|git@([^:]+):/?)([^/]+)/([^/]+?)(?:\.git|/)?$#', $url, $matches)) { return false; } diff --git a/tests/Composer/Test/Repository/Vcs/GitHubDriverTest.php b/tests/Composer/Test/Repository/Vcs/GitHubDriverTest.php index fd24a4bd4..d8efcc24c 100644 --- a/tests/Composer/Test/Repository/Vcs/GitHubDriverTest.php +++ b/tests/Composer/Test/Repository/Vcs/GitHubDriverTest.php @@ -305,14 +305,16 @@ class GitHubDriverTest extends TestCase } /** + * @dataProvider invalidUrlProvider + * @param string $url * @return void */ - public function initializeInvalidReoUrl(): void + public function testInitializeInvalidRepoUrl($url): void { $this->expectException('\InvalidArgumentException'); $repoConfig = array( - 'url' => 'https://github.com/acme', + 'url' => $url, ); $io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock(); @@ -324,6 +326,18 @@ class GitHubDriverTest extends TestCase $gitHubDriver->initialize(); } + /** + * @return list + */ + public function invalidUrlProvider() + { + return array( + array('https://github.com/acme'), + array('https://github.com/acme/repository/releases'), + array('https://github.com/acme/repository/pulls'), + ); + } + /** * @dataProvider supportsProvider * @param bool $expected @@ -345,6 +359,8 @@ class GitHubDriverTest extends TestCase array(false, 'https://github.com/acme'), array(true, 'https://github.com/acme/repository'), array(true, 'git@github.com:acme/repository.git'), + array(false, 'https://github.com/acme/repository/releases'), + array(false, 'https://github.com/acme/repository/pulls'), ); }