I am planning on working on this soon - thoughts welcome.
This is pretty critical functionality IMHO - fairly often I need to run an older stable version of a module, because the 'stable' one has a bug, and sometimes I need to run the dev branch, because a bugfix or critical feature has not yet made the latest release, or I am the module maintainer and want to work on the code as I build the site.
I am thinking that you could pass the following argument to drush pm install or update:
--version VERSION-STRING
Ideally VERSION-STRING could be a short 'friendly' string, such as 1.0-beta4 (the Drupal major version could be determined easily), a long 'friendly' string, such as 5.x-1.0-beta4, or a short or long CVS identifier, such as 1-0-beta4 or DRUPAL-5--1-0-beta4.
I would probably start with one of these and get the basic framework functional first. Possibly there is some parsing code in project module that we could use.
You could also pass either releases (CVS tags), such as 5.x-1.0-beta4 or development versions (CVS branches), such as 5.x-1.x-dev.
The only question I haven't figured out, is how this would work if you specify multiple modules on the command line. We could force a single one (a little sucky), or apply the same version to them all (pretty sucky), or just the first (confusing), or to allow multiple --version arguments (nonstandard and confusing).
An alternative, which I am leaning towards is to (instead of using a --version parameter) allow people to tag the version onto the end of the module name (in the style of the d.org download packages - i.e. drush-5.x-1.0-beta4 or drush-1.0-beta4 shorthand). This would be a bit harder to parse, but would allow you to batch install a whole bunch of modules each with distinct versions in a single command - ideal for distro packaging scripts!
Thoughts?
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | drush_pm_specific_version_fix_0.patch | 1.79 KB | owen barton |
| #11 | drush_pm_specific_version_2.patch | 8.79 KB | owen barton |
| #8 | drush_pm_specific_version_1.patch | 8.79 KB | owen barton |
| #4 | drush_pm_specific_version_0.patch | 8.72 KB | owen barton |
Comments
Comment #1
moshe weitzman commentedappending to module name looks good to me too.
Comment #2
moshe weitzman commentedAny chance of this landing soon? It can wait for 2.0 if needed.
Comment #3
clemens.tolboom+1 for naming the version commandline wise as "drush-5.x-1.0-beta4"
Comment #4
owen barton commentedHere is the patch.
The updated help explains basic usage.
I try not to get too clever with parsing major/minor version numbers etc - the update service provides an exhaustive list of possibilities, so we let that do the work. Basically we detect the version number as either -HEAD, or -[number].[number or x]*. Then we try and match this exactly with the options provided by the service. If that doesn't match we also test matching with the Drupal version branch prepended, so that you can actually leave this out if you like, as a shortcut.
If you specify the major Drupal version different from the one you are running, it will actually install that version - however I think this functionality is for advanced users, so it is easier to give them that power (sometimes you do actually want to do that - e.g. with Drupal-HEAD right now). Drupal 6 prevents you activating a module with the wrong Drupal major version (without hacking the .info first), which is a safeguard too.
Project name/version strings that should be accepted:
project
project-5.x-1.0
project-5.x-1.x-dev
project-1.0
project-1.x-dev
project-1.1-rc1
Comment #5
owen barton commentedComment #6
moshe weitzman commentedI played with this and it worked well for install but no luck for update. I will play around and see whats wrong. Thanks Grugnog2.
Comment #7
moshe weitzman commentedOwen and I chatted and decided that 'pm update' command did not work with CVS handler and this patch.
This is the last patch I would like to add before porting to Drupal6.
Comment #8
owen barton commentedI took another look at the update issue, and as far as I can tell this is really a cvs_deploy issue, rather than a drush_pm issue. Specifically I get this problem with modules marked with "Invalid info" on the update status page - if cvs_deploy is not inserting a (correct) module version to the info array then drush ignores any potential upgrades (and returns "ignored: Invalid info"), which is the existing and I think probably the safest drush behavior in this case.
If I fetch a module with wget, then the version info is returned correctly, and I have tested that I can upgrade the module with either drush_pm_cvs or drush_pm_wget.
Here is a patch that fixes the existing module check regression that we identified on IRC.
Comment #9
owen barton commentedComment #10
owen barton commentedI figured out the update problem by the way - you need the latest update_status 2.2 to work with cvs_deploy - once I had corrected that versions were correctly detected and updates installed.
It should be noted that this patch currently only allows you to install specific versions, and not update to specific versions (i.e. it will only update to the latest stable version). If we want to be able to drush pm update to an arbitrary version then this will take some work refactoring drush_pm_update().
Comment #11
owen barton commentedFixes bug with reporting project name in error/success messages
Comment #12
moshe weitzman commentedI committed this patch last night but forgot to change status. Could you please reroll with the new bits. Thx.
Comment #13
owen barton commentedHere ya go - this also removes a print_r() I found in update (from another patch, I guess)
Comment #14
moshe weitzman commentedCommitted. thanks.
I've added Grugnog2 to as a committer to drush project. Feel free to commit bug fixes and minor features directly. For bigger stuff, lets continue to use the issue queue. Thanks for all your help.
Comment #15
owen barton commentedThanks Moshe :)
Comment #16
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.