How to download specific dev version of drupal module? Simply using “git checkout” or “drush make”

How to download specific dev version of drupal module? Simply using “git checkout” or “drush make”

Dev versions of modules aren't minor versioned, they are always current. If you need specific dev version you'd have to download it from git by a date.

Latest Geocoder dev release is broken

Geocoder is a module with the latest stable release from 27 Aug 2012, therefore I use dev version. Update from 07 Jan 2016 broke some key features. The question is: How can I download a previously working snapshot?

It's possible to do it using 2 methods:

  1. git checkout” – preferred
  2. drush make” – more easier when you are not familiar with git

How to find commit hash?

In both cases you will need commit hash (2ffd3fa8b22c11100516bf801bc08ba729cc8a68):

  • Go to “View commits” (located in the right sidebar on the project page).
  • You will see a list of various dates, the commits. In my case I see 1 commit from 07 Jan 2016, 6 commits from 6 Jan 2016, 5 commits from 20 Nov 2015, 1 commit from 30 Sept 2015 etc. Click on the last commit from 20 Nov 2015.
  • You will be redirected to the page with the commit hash.

List of all commits

Commit hash

1. “git checkout” method

If you are not familiar with drupal git, start with this documentation :-D or watch this super explaining video.

If you are familiar with git, type this into a shell:

git clone --branch 7.x-1.x https://git.drupal.org/project/geocoder.git
cd geocoder
git checkout c994066d58bc7518bc9796c60d4d43f98ae477cd .

Explanation

  • git clone – you will find entire command with your-module-specific url on the project page under tab the “Version control
  • cd geocoder – git will download files into the folder “geocoder” so go there
  • cd geocoder hash . (dot) – will retrieve a date specific version of the module. Don't forget to add dot (“.”) in the end.

Desired dev version of the Geocoder module is located in "geocoder" folder, now.

2. “drush make” method

Advertisement

What's “drush make” command? This is from official documentation:

Drush make is an extension to drush that can create a ready-to-use drupal site, pulling sources from various locations. It does this by parsing a flat text file (similar to a drupal .info file) and downloading the sources it describes.

Here is a very well made video briefly explaining how the "drush make" works. Video is tied to this Jared's article.

In drush “*.make file” is defined which modules, which versions and which sources (git) you wish to use. This is sample of myMakeFile.make file I have used to retrieve specific dev version of Geocoder (November 20, 2015) from the git:

api = 2
core = 7.x
projects[drupal][version] = 7.12
projects[geocoder][version] = "1.x-dev"
projects[geocoder][download][type] = "git"
projects[geocoder][download][url] = "https://git.drupal.org/project/geocoder.git"
projects[geocoder][download][revision] = "2ffd3fa8b22c11100516bf801bc08ba729cc8a68"

Explanation

  • I don't know what api = 2 is :-)
  • core specifies a drupal version you wish to work with like 7.x, 8.x, 9.x
  • projects[drupal][version] specifies release of the Drupal you are going to download. I just copy it from this page. It will download Drupal 7.12. It's not important for the purpose of the tutorial.
  • projects[geocoder][version] says I want to download dev version of the Geocoder project.
  • projects[geocoder][download][type] I'm going to download it from a drupal git
  • projects[geocoder][download][url] git address. You can find your one on the project page under tab “Version control” as I already mentioned.
  • projects[geocoder][download][revision] hash says which commit should be the last one in the version you are going to download. I have mentioned above how to obtain this hash.

You have a drush, you have a make file and now let's run it:

cd
mkdir removeMeWhenDone
cd removeMeWhenDone
drush make /path/to/myMakeFile.make -y

Explanation

  • cd will place you into the home folder
  • mkdir removeMeWhenDone creates a temporary folder where the files will be downloaded
  • cd removeMeWhenDone – go to that tmp folder
  • drush make /path/to/myMakeFile.make -y runs the make file. “-y” says “yes” to all question Drush may have.

Desired dev version of the Geocoder module is located in ~/removeMeWhenDone/sites/all/modules, now.

Do I really have a proper version?

How to check if you have a good version:

  • Open the patch for the next commit (first one from 06 Jan 2016 in my case) and find some unique string (“Helper function to compare 2 arrays recursively.” was added).
  • It shouldn't be present in the downloaded version (version from 20 Nov 2015 in my case).
  • You can find the “unique string” in the patch attached to the issue page linked from the “hash” page (page with the commit hash).
  • Download some dev version from 06 Jan 2016 (or 07 Jan 2016), and try to search for the "unique string" within the module files. It should be present.

That's it, you have learned how to download specific dev version of Drupal module using 2 methods – “drush make” and “git checkout.

Advertisement

Post is listed in the Drupal category and marked with the following tag(s): Git, Drush, Modules.