2

I tried to manage drupal modules with the --package_handler=git_drupalorg which needed me to add the --gitinfofile option. Using drush dl this works but if I try to update my modules with drush up the version information is the same as of the drush dl version. Is there a fix for this or a guide which explains how to use drush with the git version control system. I am using the drush 6.2.0 version.

  • Come on. No one using this feature and has the same problem? What is your workflow then? – grossmann-mcs May 13 '14 at 6:42
0

Update: As mentioned in the comments below, the actual answer here is that the git deploy module is required for --package-handler=git_drupalorg to work correctly.

If you just want to track the latest HEAD from some branch of some module, then you can use drush dl with --package-handler=git_drupalorg to download the file, and use git pull when you want to update your code.

drush pm-updatecode is best used in instances where you wish to track the latest stable release of the module.

| improve this answer | |
  • The problem is not using drush drush dl or drush upc. The problem is using dl with --gitinfofile updates the .info file correctly while using upc or up does not change the version information in the .info file. This way the update status becomes outdated and even wrong as the code is version 1.1 and .info says version = "7.x-1.0". – grossmann-mcs May 14 '14 at 10:49
  • I found that trying to use --gitinfofile is more complicated than helpfull. I tried the module git_deploy and it seems to do the trick even as I thought this shouldn't be required any more. – grossmann-mcs May 14 '14 at 10:57
  • Sorry, yes, you are correct -- git_deploy is necessary. – greg_1_anderson May 14 '14 at 13:30
0

I have this solution that has worked well for me, but requires a 1-line hack of a drush file, so use it at your own risk. Really the only problem is to remember to redo the hack when you upgrade drush. Below I broke it all down for completeness.

1) For download

drush pm-download MODULE_NAME --package-handler=git_drupalorg --gitinfofile

2) For update

drush pm-update MODULE_NAME --package-handler=git_drupalorg --gitinfofile --gitcheckoutparams=-f

To make these your default options, add the following to sites/all/drush/drushrc.php

$options['package-handler'] = 'git_drupalorg';
$command_specific['pm-download'] = array('gitinfofile' => TRUE);
$command_specific['pm-update'] = array('gitinfofile' => TRUE, 'gitcheckoutparams' => '-f');
$command_specific['pm-updatecode'] = array('gitinfofile' => TRUE, 'gitcheckoutparams' => '-f');

3) Put the following hook in sites/all/drush/SITENAME.drush.inc

/**
* Implements HOOK_pm_post_update().
* NOTE: Bottom section of package_handler_post_download($project, $release)
*       from file PATH2DRUSH/drush/commands/pm/package_handler/git_drupalorg.inc
*/
function SITENAME_pm_post_update($project) {
  $release = $project['releases'][$project['candidate_version']];
  if (drush_get_option('gitinfofile', FALSE)) {
    $matches = array();
    if (preg_match('/^(.+).x-dev$/', $release['version'], $matches)) {
      $full_version = drush_pm_git_drupalorg_compute_rebuild_version($project['full_project_path'], $matches[1]);
    }
    else {
      $full_version = $release['version'];
    }
    drush_pm_inject_info_file_metadata($project['full_project_path'], $project['name'], $full_version);
  }
}

4) Hack drush file PATH2DRUSH/drush/commands/pm/updatecode.pm.inc

/**
 * Run the post-update hooks after updatecode is complete for one project.
 */
function pm_update_complete($project, $version_control) {
  drush_print(dt('Project !project was updated successfully. Installed version is now !version.', array('!project' => $project['name'], '!version' => $project['candidate_version'])));
  // HACK - send over entire $project to all HOOK_pm_post_update implementations
  //drush_command_invoke_all('pm_post_update', $project['name'], $project['releases'][$project['candidate_version']]);
  drush_command_invoke_all('pm_post_update', $project);
  $version_control->post_update($project);
}
| improve this answer | |
  • Does git deploy not do the trick for you? You can remove your addition to pm_update_complete if you rename your hook to drush_SITENAME_post_pm_updatecode. You can recover $project via $updated = drush_get_context('DRUSH_PM_UPDATED');. $updated is an array of $project(s). – greg_1_anderson May 23 '14 at 13:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.