A simple shell command for drupal cvs checkouts
#!/bin/bash
cvs -z6 -d:pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal-contrib checkout -r DRUPAL-$2 -d $1 contributions/modules/$1There are lots of great Drupal productivity / development modules (e.g. drush, devel, coder) which due to their nature as modules need to be installed on each site you work on. If you work on a dizzying number of different Drupal sites, productivity improvements which are not site-specific are the most useful.
NB: this post is geared toward Mac users.
For Textmate I now have both the BoldSource bundle and the PHP Drupal bundle, which are both new. I also make great use of the Wim Leers command to instantly look up Drupal API functions from Textmate.
For the shell I sometimes use Steven Wittens' diff shortcut, and I also followed Textmate's instructions so that I can open files and projects in Textmate with the mate command (it always saves time to avoid Finder, whether via Quicksilver or command line).
If you ever (perpetually?) find yourself having to debug contributed modules it is important that you always download your modules from cvs- otherwise you will not be able to submit a patch for your work and will soon find yourself fixing the same thing again for your next project. Getting your modules from cvs is actually faster than downloading them from your browser and unpacking them into the right folder, but the cvs command itself can slow you down. For a while I have been using an alias to simplify checking out Drupal modules via cvs but I finally got around to setting up a proper bash command. I am pretty new to the wild world of command line geekery, but this is how I added a new command:
From your home directory, edit your .bash_profile file
cd ~
mate .bash_profile (or use another editor: vi .bash_profile)
(If you don't already have a .bash_profile file it will be created)
Add the line
export PATH=/usr/local/bin:$PATH
where /usr/local/bin will be the directory where you will add new commands. You can use a different directory if you please.
Navigate to that path where you can add new commands.
cd /usr/local/bin
The commands are just text files where the name of the command is the filename. I call my drupal cvs module checkout command 'drcvs'.
mate drcvs
Add the following:
#!/bin/bash
cvs -z6 -d:pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal-contrib checkout -r DRUPAL-$2 -d $1 contributions/modules/$1Save the file and open a new shell. (You have to open a new shell for the .bash_profile changes to register.) You can now use the new command.
I use drcvs views 5--1-6 to do a checkout of views into my current directory. (I look up the version I want on the project page first.)














Thanks
That is a handy script.
Much appreciated.
>air guitar<
Cool :)
Thanks Jody... Definitely makes life easier!
BTW, for anyone getting "permission denied" change the file permissions...
cd /usr/local/binsudo chmod 755 drcvs:)
Yes--
Forgot to mention that step!
I'm trying this on Ubuntu
I'm trying this on Ubuntu but it isn't working.
.../sites/all/modules$ dpl-get-module pathauto 5--2
cvs server: cannot find module `pathauto' - ignored
cvs server: cannot find module `5--2' - ignored
cvs [checkout aborted]: cannot expand modules
Any ideas?
Oh
I just noticed the problem, I was trying to use an alias.
I added this function/command to .bashrc in my home folder.
dpl_get_module () {
cvs -z6 -d:pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal-contrib checkout -r DRUPAL-"$2" -d "$1" contributions/modules/"$1"
}
Don't forget to do
source .bashrcafter saving.Post new comment