Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Drush to search recursively inside any specified alias path. #1480

Merged
merged 2 commits into from
Jul 7, 2015

Conversation

greg-1-anderson
Copy link
Member

Currently, Drush only considers alias files that appear immediately inside any given alias searchpath directory. This PR expands the search to include any directory that is anywhere deep inside any specified searchpath directory.

For the most part, this should not cause Drush to search for alias files too deeply. The current default alias search path only includes folders that are specific to Drush. For example:

  /etc/drush
  $HOME/.composer/vendor/drush/drush
  $HOME/.drush
  $ROOT/drush
  $ROOT/sites/all/drush
  $ROOT/../drush

I'm not sure why Drush searches its own directory for aliases, but it does.

These directories do, for the most part, only contain Drush files, and therefore should not be too crowded with deeply-nested folders. The one exception here is $HOME/.drush, which might contain a 'vendor' directory if folks use the recommended cd $HOME/.drush && composer include ... technique to get global Drush commandfiles that are managed by composer. In this case, there might be some very deep hierarchies that we'd rather not search.

To work around this, this PR further restricts searching to inside a folder 'aliases', if it exists in any search location. If a folder named 'aliases' does not exist, then the entire search location is searched.

I suppose an alternate idea would be to deeply search $LOCATION/aliases, and also consider alias files contained directly inside $LOCATION. In this instance, though, the --alias-path location should probably always be searched recursively. This is slightly awkward vis-a-vis the current implementation of alias file searching, but not insurmountably so.

@weitzman
Copy link
Member

weitzman commented Jul 7, 2015

I think the proposed implementation looks good.

  1. I prefer to longer site-aliases folder name. That disambiguates from command aliases and shell aliases.
  2. Lets update any docs that you can find on this topic.
  3. I think it is unwise to backport this but I'm open to discussion if desired.

…o search for alias files. Add documentation in example.aliases.drushrc.php.
@greg-1-anderson
Copy link
Member Author

I agree that we should not backport this. If someone strongly desires this behavior in an older version of Drush, we could consider turning it on with an option. At that point, though, you might as well set $options['alias-path'] in your drushrc.php, and explicitly list all of the folders you want searched. So, probably no backport.

I made the changes you suggested in #1 and #2 in the commit above.

* for alias files.
*/
public function testDeepAliasSearching() {
$aliasPath = UNISH_SANDBOX . '/aliases';
Copy link
Member

Choose a reason for hiding this comment

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

should this be site-aliases?

Copy link
Member Author

Choose a reason for hiding this comment

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

No; this is passed as --alias-path, which is always searched recursively, regardless of whether there is a 'site-aliases' directory or not (since the path was explicitly provided by the user).

I could change this to '/site-alias-directory' or something like that, for the avoidance of doubt.

@weitzman
Copy link
Member

weitzman commented Jul 7, 2015

Ready to merge after you address the minor line comments above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants