-
Notifications
You must be signed in to change notification settings - Fork 114
Issue #42 A better way to manage the version on install #90
Conversation
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)) { |
There was a problem hiding this comment.
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 = '') |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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)) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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+
There was a problem hiding this comment.
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. :)
There was a problem hiding this comment.
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 :/
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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 ?
Voilà ! Relied on the 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)) { |
There was a problem hiding this comment.
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
Fixed @stof's note about the regexp :) |
We should probably provide a sensible error message if the installer wasn't able to find the latest patch version. |
@xabbuh Here it is :) I added the message only when |
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', |
There was a problem hiding this comment.
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.
Hi @xabbuh , is this PR ok for merging ? 😄 |
@Pierstoval I'm not the one to decide, but to me it looks ready. :) |
Fine, thanks ! We'll just wait for it to be merged, I think it's an awesome feature ! |
Thanks @Pierstoval for working on this feature. The Symfony Installer is now almost complete! |
No description provided.