11

Is there any way to clone or pull the HEAD version of a module in drupal.org git repository?

For example, if I'm on Drupal 7, and the last branch of Views is 3, I would like to do:

drush git-clone views

to achieve something equivalent to:

cd sites/all/modules/
git clone --recursive --branch 7.x-3.x http://git.drupal.org/project/views.git

Ideally, using drush git-clone views-3x should clone the 3.x branch explicitly.

Is this possible or am I dreaming? This would be really useful for developing.

1 Answer 1

10
drush dl views-7.x-3.x --package-handler=git_drupalorg

Update:

True, if there are commits after the dev release was packaged, you will need to run git pull to advance to HEAD after checking out via drush dl. If there is no packaged dev release, and Drush checks out a stable release, then you need to run git checkout 7.x-3.x after drush dl.

There is no Drush command to do a verbatim git clone; part of the "value add" of drush dl is that it grabs published releases. If git clone is what you want, perhaps a short bash script would be your best solution. Something like this:

Usage:

$ clonedev views 3

Example script:

#!/bin/bash

MODULE=$1
VERSION=$2

DRUPAL=$(drush status "Drupal Version" --pipe | sed -e 's/\..*//')
if [ -n $DRUPAL ] ; then
  cd $(drush drupal-directory modules)
else
  DRUPAL=7
fi

git clone --recursive --branch $DRUPAL.x-$VERSION.x http://git.drupal.org/project/$MODULE.git

Modify to suit.

2
  • I've just tried it, and it downloads the latest dev release, not HEAD. And if there is no dev release available, it downloads the latest recommended or supported release.
    – Pere
    Commented Feb 20, 2013 at 16:16
  • Okay, see updated answer. Commented Feb 20, 2013 at 17:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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