Skip to content
This repository was archived by the owner on Nov 14, 2019. It is now read-only.

Improve the installation of -dev and -BETA versions #185

Merged
merged 13 commits into from
Sep 28, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 22 additions & 8 deletions src/Symfony/Installer/NewCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,14 @@ protected function execute(InputInterface $input, OutputInterface $output)
protected function checkSymfonyVersionIsInstallable()
{
// 'latest' is a special version name that refers to the latest stable version
// available at the moment of installing Symfony
if ('latest' === $this->version) {
return $this;
}

// 'lts' is a special version name that refers to the current long term support version
if ('lts' === $this->version) {
if (in_array($this->version, array('latest', 'lts'))) {
return $this;
}

// validate semver syntax
if (!preg_match('/^2\.\d(?:\.\d{1,2})?$/', $this->version)) {
throw new \RuntimeException('The Symfony version should be 2.N or 2.N.M, where N = 0..9 and M = 0..99');
if (!preg_match('/^2\.\d(?:\.\d{1,2})?(?:-(?:dev|BETA\d*|RC\d*))?$/i', $this->version)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could now pass a patch version and a dev suffix. I think both parts should be exclusive.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dev suffixes are all rejected just later, so this is not a big deal IMO

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, but this does not only apply to the -dev suffix but also to -BETA and -RC.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and beta versions are named 2.1.0-beta, not 2.1-beta

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm indeed, then we can move that part of the regex.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed this regular expression by:

if (!preg_match('/^2\.\d(?:\.\d{1,2})?|2\.\d(?:-(?:dev|BETA\d*|RC\d*))$/i', $this->version))

Please review it. Thanks!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you forget to push the changes?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've pushed it .... and then reverted it. The correct beta version is x.y.z-BETAn, not x.y-BETAn

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There would still be some versions that pass the regex but are not valid. Though actually the installer will fail with a meaningful message anyway later on. So I think it's okay if we just stick with this solution.

throw new \RuntimeException('The Symfony version must be 2.N or 2.N.M (where N and M are positive integers). The special "-dev", "-BETA" and "-RC" versions are also supported.');
}

if (preg_match('/^2\.\d$/', $this->version)) {
Expand Down Expand Up @@ -175,6 +170,25 @@ protected function checkSymfonyVersionIsInstallable()
));
}

// "-dev" versions are not supported because Symfony doesn't provide packages for them
if (preg_match('/^.*\-dev$/i', $this->version)) {
throw new \RuntimeException(sprintf(
"The selected version (%s) cannot be installed because it hasn't\n".
"been published as a package yet. Read the following article for\n".
"an alternative installation method:\n\n".
"> How to Install or Upgrade to the Latest, Unreleased Symfony Version\n".
'> http://symfony.com/doc/current/cookbook/install/unstable_versions.html',
$this->version
));
}

// warn the user when downloading an unstable version
if (preg_match('/^.*\-(BETA|RC)\d*$/i', $this->version)) {
$this->output->writeln("\n <bg=red> WARNING </> You are downloading an unstable Symfony version.");
// versions provided by the download server are case sensitive
$this->version = strtoupper($this->version);
}

return $this;
}

Expand Down
6 changes: 6 additions & 0 deletions tests/Symfony/Installer/Tests/IntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ public function provideSymfonyInstallationData()
'/.*Symfony 2\.5\.6 was successfully installed.*/',
'/Symfony version 2\.5\.6 - app\/dev\/debug/',
),

array(
'2.7.0-BETA1',
'/.*Symfony 2\.7\.0\-BETA1 was successfully installed.*/',
'/Symfony version 2\.7\.0\-BETA1 - app\/dev\/debug/',
),
);
}
}