Closed (fixed)
Project:
Drush
Component:
Base system (internal API)
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
19 Nov 2011 at 00:59 UTC
Updated:
11 Feb 2012 at 15:32 UTC
Jump to comment: Most recent file
If you have two aliases, @site1.dev and @site2.dev (both named "dev" in their respective files site1.aliases.drushrc.php and site2.aliases.drushrc.php), then any usage of the alias @dev is the merged results of the fields of the unrelated aliases.
This, as you might imagine, can produce phenomenally bad results. The attached patch insures that in these instances, an arbitrary alias of the correct name is returned. All tests still pass.
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | multiple-matches-handling-8.patch | 18.53 KB | greg.1.anderson |
| #6 | multiple-matches-handling-6.patch | 23.51 KB | greg.1.anderson |
| #4 | multiple-matches-handling.patch | 23.39 KB | greg.1.anderson |
| do-not-merge-aliases.patch | 15.97 KB | greg.1.anderson |
Comments
Comment #1
greg.1.anderson commentedRemoving #hidden was dubious. I'm going to work on this some more.
Comment #2
greg.1.anderson commentedHere is a patch with better handling of multiple matches than before. If you attempt to use '@dev' when multiple aliases files contain aliases that match that name, you will now get an "ambiguous result" warning followed by a "no alias matched" error. This avoids the rather large problem that can be caused by the current technique of merging unrelated alias records together.
If you wish to operate on multiple aliases, the 'all' groupname can be used; e.g.:
drush @all.dev statuswill display status for all '@dev' aliases. It is also possible to leave off the group name from the alias if drush can infer which group is intended by way of the other aliases used in the same command; e.g.:drush sql-sync @site.live @devwill prefer @site.dev if it can be found.All tests pass; if the code looks good, I'll update up the docs and add a change notification.
Comment #3
moshe weitzman commentedMissing patch.
I'm not too fond of more magic in site alias system like "drush sql-sync @site.live @dev will prefer @site.dev if it can be found.". I think this complicates an already difficult system.
Comment #4
greg.1.anderson commentedHere is the missing patch. I could remove the feature mentioned in #3 if desired, but it is important to replace the current record-merging behavior with something more reasonable. Hopefully most of this patch will be acceptable.
Comment #5
greg.1.anderson commentedI had an idea to make this feature more explicit that would only take a little bit of code to implement.
"@related." === the same group as another alias in use:
drush @site.dev site-alias @related.live===drush site-alias @site.livedrush rsync @site.dev @related.live===drush rsync @site.dev @site.liveTo shorten typing this, "@." === "@related.":
drush rsync @site.dev @.live===drush rsync @site.dev @site.liveThe main use of this, though, is not the nominal usefulness of reducing typing on the cli, but to make scripts and shell aliases more flexible. For example:
$options['shell-aliases']['pull-data'] = '!drush sql-sync @related.live {{@target}} && drush rsync @related.live:%files {{@target}}:%files'
Usage:
drush @site.dev pull-dataWith just a touch more work, {{@target}} could probably become @self. With a few useful examples in drush topic docs-shell-aliases, it wouldn't be too hard for folks to create customized workflows the pull from live or stage or wherever is appropriate for their dev environment.
If this looks good, I'll roll a new patch.
Comment #6
greg.1.anderson commentedHere is a patch that supports the constructs described #5; it is nearly the same as #4.
Comment #7
moshe weitzman commentedFor me, this @related magic is too much. I would personally redefine pull-data on each site that I worked on. I propose that we just fix the bug at hand for now.
Comment #8
greg.1.anderson commentedHere is a fix for multiple match handling that does not add any well-known-groupname magic. All tests pass.
Comment #9
greg.1.anderson commentedComment #10
moshe weitzman commentedThanks.
Comment #11
greg.1.anderson commentedCommitted.
Comment #12
greg.1.anderson commentedForgot to set status.
Comment #14
moshe weitzman commentedhttp://drupal.org/node/1436964