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

Issue #42 A better way to manage the version on install #90

Closed
wants to merge 8 commits into from
Closed

Issue #42 A better way to manage the version on install #90

wants to merge 8 commits into from

Conversation

Pierstoval
Copy link
Contributor

No description provided.

if (!preg_match('/^2\.\d\.\d{1,2}$/', $this->version)) {
throw new \RuntimeException('The Symfony version should be 2.N.M, where N = 0..9 and M = 0..99');
// validate server syntax
if (!preg_match('/^(2\.\d\.\d{1,2}|2\.\d)$/', $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.

I would use parentheses to distinguish between the two forms of versions:

/^(2\.\d\.\d{1,2})|(2\.\d)$/

* @return string
*/
private function getExecutedCommand()
private function getExecutedCommand($version = '')
Copy link
Member

Choose a reason for hiding this comment

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

this argument does not seem to be used

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, was used in the first commit when throwing an exception which proposed to the user to install the latest version instead of the one he was trying to install.
I'm gonna remove it, as this error has been deleted in the last fix commit

Fixes for #90, the exception when checking for minor version is no more thrown so the `$version` behavior has to come back to its original mode.
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})|(2\.\d)$/', $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.

Why do you do the check again here? If the regex didn't match, an exception would have been thrown and this code wouldn't be reached.

Copy link
Member

Choose a reason for hiding this comment

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

But you could check for ^2\.d$ to only execute the following lines if the user didn't specify a patch version.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In fact I meant to check 2\.[0-9]+ , I saw your note about changing the regex but now I see that these lines look alike very VERY much in the previous diff, and I realize that I should have never changed this regex in fact.
I'm gonna change it, but as a reminder, this line should only check for minor versions, so I'll change back the regex to 2\.\d+

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I just had a look at 33e4966 and it seems that you just modified the wrong regex. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, indeed.
Moreover, would it be good to rewrite these regexes for higher minor/patch versions compatibility ?
I mean, on the line 126, changing /^(2\.\d\.\d{1,2}|2\.\d)$/ for /^2\.\d+(\.\d+)?$/ ? It's more readable to me but I don't know if it's a better practice for other developers :/

Copy link
Member

Choose a reason for hiding this comment

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

I think /^2\.\d(\.\d{1,2})?$/ is fine (just keep {1,2} here, iirc it was added on purpose).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok fine.

When Symfony3 will be released for first stabilization process, we may change the 2\. part into [23]\. in every regex , don't we ?

@Pierstoval
Copy link
Contributor Author

Voilà ! Relied on the json() method from the ResponseInterface, in order to facilitate the modification of the Guzzle's Response.

I think we're good for this issue, aren't we ?

if (!preg_match('/^2\.\d\.\d{1,2}$/', $this->version)) {
throw new \RuntimeException('The Symfony version should be 2.N.M, where N = 0..9 and M = 0..99');
// validate server syntax
if (!preg_match('/^2\.\d(\.\d{1,2})?$/', $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.

please use a non-capturing group

@Pierstoval
Copy link
Contributor Author

Fixed @stof's note about the regexp :)

@xabbuh
Copy link
Member

xabbuh commented Dec 27, 2014

We should probably provide a sensible error message if the installer wasn't able to find the latest patch version.

@Pierstoval
Copy link
Contributor Author

@xabbuh Here it is :) I added the message only when $versionsList is not empty, because if it is, it means that Guzzle couldn't connect to symfony.com, so the user won't be able to download Symfony anyway.

throw new \RuntimeException(sprintf(
"The selected branch (%s) does not exist, or is not maintained.\n".
"To solve this issue, install Symfony with the latest stable release:\n\n".
'%s %s %s latest',
Copy link
Member

Choose a reason for hiding this comment

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

latest is the default value and you can omit it here.

@Pierstoval
Copy link
Contributor Author

Hi @xabbuh , is this PR ok for merging ? 😄

@xabbuh
Copy link
Member

xabbuh commented Jan 2, 2015

@Pierstoval I'm not the one to decide, but to me it looks ready. :)

@Pierstoval
Copy link
Contributor Author

Fine, thanks ! We'll just wait for it to be merged, I think it's an awesome feature !
I just installed a new SF2.6 app some days ago and was surprised that I couldn't do "new app/ 2.6" , when I remembered that it was only available in my local machine 😆

@javiereguiluz
Copy link
Member

Thanks @Pierstoval for working on this feature. The Symfony Installer is now almost complete!

javiereguiluz added a commit to javiereguiluz/symfony-installer that referenced this pull request Jan 2, 2015
javiereguiluz added a commit that referenced this pull request Jan 2, 2015
… introduced by #90 (javiereguiluz)

This PR was merged into the 1.0-dev branch.

Discussion
----------

Updated the Installer instructions to keep with the changes introduced by #90

Commits
-------

40064a5 Updated the Installer instructions to keep with the changes introduced by #90
@Pierstoval Pierstoval deleted the issue42 branch February 28, 2015 10:20
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants