Index: commands/pm/pm.drush.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/drush/commands/pm/pm.drush.inc,v retrieving revision 1.116 diff -u -r1.116 pm.drush.inc --- commands/pm/pm.drush.inc 16 Jun 2010 15:08:02 -0000 1.116 +++ commands/pm/pm.drush.inc 17 Jun 2010 23:28:34 -0000 @@ -1203,6 +1203,12 @@ 'drush [command] cck --cvsmethod=update' => 'Will update the project, and try to merge changes, rather than overwriting them. Any conflicts will need to be resolved manually.', ), ), + 'git_drupalorg' => array( + 'options' => array( + '--package-handler=git_drupalorg' => 'Use git.drupal.org to checkout and update projects.', + '--gitsubmodule' => 'Use git submodules for checking out new projects. Existing git checkouts are unaffected, and will continue to (not) use submodules regardless of this setting.', + ), + ), ); } Index: commands/pm/package_handler/git_drupalorg.inc =================================================================== RCS file: commands/pm/package_handler/git_drupalorg.inc diff -N commands/pm/package_handler/git_drupalorg.inc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ commands/pm/package_handler/git_drupalorg.inc 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,121 @@ + $project['name'], '!dir' => $project['base_project_path']))); + return FALSE; + } + + // Create the project path and find its true location, git submodule doesn't + // like symbolic links. + mkdir($project['full_project_path']); + $full_project_path = realpath($project['full_project_path']); + rmdir($full_project_path); + + // Add the submodule; this clones it into place and registers it in the + // superproject. + $commands = array(); + $commands[] = 'cd ' . escapeshellarg($git_dir . '/..'); + $commands[] = 'git submodule add ' . escapeshellarg($repository) . ' ' . escapeshellarg($full_project_path); + $commands[] = 'cd ' . escapeshellarg($project['full_project_path']); + $commands[] = 'git checkout ' . escapeshellarg($tag); + + if (!drush_shell_exec(implode(' && ', $commands))) { + drush_set_error('DRUSH_PM_UNABLE_CHECKOUT', 'Unable to retrieve ' . $project['name'] . ' from git.drupal.org.'); + return FALSE; + } + else { + return TRUE; + } +} + +/** + * Update a project (so far, only modules are supported). + * + * @param $project The project array with name, base and full (final) paths. + * @param $release The release details array from drupal.org + */ +function package_handler_update_project($project, $release) { + drush_log('Updating project ' . $project['name'] . ' ...'); + + $commands = array(); + $commands[] = 'cd ' . escapeshellarg($project['full_project_path']); + + if ($release['version_extra'] == 'dev') { + // Update the branch of the development repository. + $commands[] = 'git pull'; + } + else { + // Use a stable repository. + $commands[] = 'git fetch'; + $commands[] = 'git checkout ' . escapeshellarg($release['version']); + } + + if (!drush_shell_exec(implode(' ; ', $commands))) { + drush_set_error('DRUSH_PM_UNABLE_CHECKOUT', 'Unable to update ' . $project['name'] . ' from git.drupal.org.'); + return FALSE; + } + else { + return TRUE; + } +}