When downloading a module with package manager set to git_drupalorg and gitsubmodule set to TRUE, the module is downloaded to the correct location, but the submodule is set to a directory with the module name in the project root. For example /simpletest is used, not /sites/all/modules/simpletest.

Dumping the command array in git_drupalorg.inc showed that the destination arg was set to FALSE instead of a string:

array(4) {
  [0]=>
  string(17) "git submodule add"
  [1]=>
  NULL
  [2]=>
  string(43) "git://git.drupal.org/project/simpletest.git"
  [3]=>
  bool(false)
}

Checking out the $project array, it looks like the value of full_project_path may have changed from a full path to a relative path, so the substr call is now failing. Here's the dump of $project:

array(10) {
  ["name"]=>
  string(10) "simpletest"
  ["version"]=>
  NULL
  ["drupal_version"]=>
  string(3) "6.x"
  ["project_version"]=>
  NULL
  ["project_type"]=>
  string(6) "module"
  ["project_dir"]=>
  string(10) "simpletest"
  ["base_project_path"]=>
  string(10) "simpletest"
  ["full_project_path"]=>
  string(36) "sites/all/modules/contrib/simpletest"
  ["repository"]=>
  string(43) "git://git.drupal.org/project/simpletest.git"
  ["project_install_location"]=>
  string(36) "sites/all/modules/contrib/simpletest"
}

Using $project['full_project_path'] without the substr parsing fixed the issue.

CommentFileSizeAuthor
#1 gitsubmodule-path-1314554-1.patch918 bytesethanw

Comments

ethanw’s picture

Issue summary: View changes

Formatted var dumps with code.

ethanw’s picture

StatusFileSize
new918 bytes

Patch attached.

rfay’s picture

Title: gitsubmodule does not use module destination for submotule » gitsubmodule does not use module destination for submodule (ignores --destination)
Status: Needs review » Reviewed & tested by the community

Yup, this patch fixes this problem for me.

Without the patch, if, with gitsubmodule enabled, you do a

drush dl --destination=sites/all/modules ctools-7.x-1-x-dev

Ctools will be cloned... and it will tell you it's looking at sites/all/modules... but when it's all done the module will be in modules instead of sites/all/modules

moshe weitzman’s picture

Assigned: Unassigned » jonhattan

Hopefully jonhattan can review and commit. If he is unavailable, I will do so in a couple days.

jonhattan’s picture

Status: Reviewed & tested by the community » Needs work

The source of the problem is earlier.

$ drush dl --package-handler=git_drupalorg --gitsubmodule ctools

Project ctools (7.x-1.0-rc1) downloaded to /var/www/drupal-7.9/sites/all/modules/ctools.                                                                                          [success]
Array
(
    [name] => ctools
    [version] => 
    [drupal_version] => 7.x
    [project_version] => 
    [project_type] => module
    [project_dir] => ctools
    [base_project_path] => ctools
    [full_project_path] => /var/www/drupal-7.9/sites/all/modules/ctools
    [repository] => git://git.drupal.org/project/ctools.git
    [project_install_location] => /var/www/drupal-7.9/sites/all/modules/ctools
)
$ drush dl --package-handler=git_drupalorg --gitsubmodule --destination=sites/all/modules ctools-7.x-1.x-dev
Project ctools (7.x-1.x-dev) downloaded to sites/all/modules/ctools.                                                                                                              [success]
Array
(
    [name] => ctools
    [version] => 7.x-1.x-dev
    [drupal_version] => 7.x
    [project_version] => 1.x-dev
    [project_type] => module
    [project_dir] => ctools
    [base_project_path] => ctools
    [full_project_path] => sites/all/modules/ctools
    [repository] => git://git.drupal.org/project/ctools.git
    [project_install_location] => sites/all/modules/ctools
)
jonhattan’s picture

Title: gitsubmodule does not use module destination for submodule (ignores --destination) » dl --destination sets a relative path for project_install_location
jonhattan’s picture

Version: » All-versions-4.x-dev
Assigned: jonhattan » msonnabaum
Status: Needs work » Patch (to be ported)

fixed in master.

moshe weitzman’s picture

Version: All-versions-4.x-dev »
Assigned: msonnabaum » jhedstrom
Status: Patch (to be ported) » Needs work

I'm seeing a new bug with --destination. Notice 'Array' below:

~/tmp$ drush dl  drupal-6 --destination=/tmp  --yes --cache -v
Executing: wget --version
Downloading release history from http://updates.drupal.org/release-history/drupal/6.x                                                                   [notice]
http---updates.drupal.org-release-history-drupal-6.x retrieved from cache.                                                                              [notice]
Downloading project drupal to /tmp/drush_tmp_1321410591 ...                                                                                             [notice]
http---ftp.drupal.org-files-projects-drupal-6.22.tar.gz retrieved from cache.                                                                           [notice]
Downloading drupal-6.22.tar.gz was successful.                                                                                                          [notice]
Md5 checksum of drupal-6.22.tar.gz verified.                                                                                                            [notice]
Executing: tar -C /tmp/drush_tmp_1321410591 -xzf http---ftp.drupal.org-files-projects-drupal-6.22.tar.gz
Executing: tar -tzf http---ftp.drupal.org-files-projects-drupal-6.22.tar.gz
Executing: svn info Array//tmp
Executing: bzr root Array//tmp
Install location Array//tmp/drupal-6.22 already exists. Do you want to overwrite it? (y/n): y
Project drupal (6.22) downloaded to Array//tmp/drupal-6.22.                                                                                          [success]
Project drupal contains:                                                                                                                             [success]
 - 1 profile: default
 - 6 themes: pushbutton, minnelli, garland, marvin, chameleon, bluemarine
 - 33 modules: user, upload, update, trigger, translation, tracker, throttle, taxonomy, system, syslog, statistics, search, profile, poll, ping, php,
path, openid, node, menu, locale, help, forum, filter, dblog, contact, comment, color, book, blogapi, blog, block, aggregator

Executing: wget -q -O - --no-check-certificate --timeout=5 --header="Content-Type: application/json" --post-data '[{"date":1321410591,"cmd":"pm-download","opt":{"5":"gitusername","9":"cache","11":"destination"},"major":"5","minor":"0-dev","os":"Darwin"}
]' 'https://api.mongolab.com/api/1/databases/usage/collections/usage?apiKey=4eb95456e4b0bcd285d8135d'
Command dispatch complete  
jhedstrom’s picture

Assigned: jhedstrom » jonhattan

I think you meant to assign this to jonhattan

jonhattan’s picture

Status: Needs work » Fixed

Fixed and added tests for it.

http://drupalcode.org/project/drush.git/commitdiff/f7382c4?hp=3566e6b72d...

Also I didn't realize there were commits to test --select conflicting me. So I did a merge and separate --select checks to its own test/function. Hope this is right: http://drupalcode.org/project/drush.git/commitdiff/782917a

jonhattan’s picture

Version: » All-versions-4.x-dev
Assigned: jonhattan » msonnabaum
Status: Fixed » Patch (to be ported)
msonnabaum’s picture

Assigned: msonnabaum » Unassigned
Status: Patch (to be ported) » Fixed

Fix and new tests backported.

rfay’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

Formatted var dumps with code.