0

I use a git repository, and Drush to manage Drupal projects.

What I would like to do now is to add more then 100 contributed modules to the git repository to keep track on these modules as well.

If I am forced to add contributed modules manually, I have to do the following steps over 100 times:

drush dl <contributed module name>
git add .
git commit -m "<contributed module name> <contributed module version> imported"

I would like to avoid or limit this manual task. Is there any automated way to do this?

2
  • I am looking for a linux shell script to automatically download contributed modules and add these modules to git repository and commit changes module by module. The script should contain a list (or array) of contributed module names and preferably automatically choose the latest stable contributed module version as described above. – Refineo Oct 27 '11 at 21:48
  • Why can't you add them all in the same commit? I don't find pushing 100 different commits adding modules particularly useful. – Pere Jun 15 '14 at 18:06
2

You can use submodule on if you want keep tracking all latest commit for each project, but that means that your project can have development code from one of these modules.

Or, you can also download all your 100 modules with Drush and just do a git add . in the parent directory (git add all files recursively).

2
  • Yvan, thank you for your hints. Actually I do not need to track every single commit for these contributed modules' projects however I would like to keep track of what module version was installed and when. I would like to keep commits separated for each contrib modules download and only make this process more automated mainly to avoid errors and to be able to repeat it. – Refineo Oct 27 '11 at 18:31
  • To keep track of all installed modules and their dependencies check Features and Master modules – Pere Jun 15 '14 at 18:07
0

I wrote a short bash script (below) that simplifies this process a bit but is not perfect.

Can someone suggest a more flexible solution ?

function drush_dl_add_commit()
{

    dr_module=${1}
    dr_version=${2}

    drush dl "${dr_module}-${dr_version}"
    git add .
    git commit -m "${dr_module} (${dr_version}) imported"

}

drush_dl_add_commit profile2 7.x-1.0
drush_dl_add_commit progress 7.x-1.0
drush_dl_add_commit purr_messages 7.x-2.0-beta2

How to automatically select the latest stable module version so the following would work without errors/warning messages ?

drush_dl_add_commit profile2
drush_dl_add_commit progress
drush_dl_add_commit purr_messages
2
  • drush dl <module_name> automatically downloads the latest stable version. – karth Oct 28 '11 at 5:59
  • Yes, thank you. I could also use drush dl -y "${dr_module}" to skip interactive messages. – Refineo Oct 28 '11 at 9:24

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.