Drupal CVS Checkout Shortcuts

I've recently found myself having to constantly search for the CVS checkout command for drupal modules. Rather than memorizing it, I figured it was easier to create a script that does checkouts for me. Better yet, I found others who have already done that part for me. Here are some really slick .bashrc or .bash_profile scripts for dealing with CVS, SVN, and Drupal:

Checking Out a Module

The following checks out the specified HEAD version of a contrib module. Running this will 1) check out the module specified from CVS into a folder of the same name within the current folder, and 2) list all the available revisions you can update your new module to (recommended since you currently just checked out HEAD).

# Get a new drupal module
getmod()
{
MODULE="${1}";
cvs -z6 -d:pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal-contrib co -d ./$MODULE contributions/modules/$MODULE;
cd $MODULE;
getrevs $MODULE.module
}

Example: getmod cck
Note: This function requires you define another function that is covered below (getrevs())

List a Module's Available Revisions

This function is great because it prevents you from having to a) guess the latest stable release or b) checking the latest release version on the project page.

# List the revisions of the supplied file
getrevs()
{
cvs log "${1}" | egrep 'DRUPAL-.*:' | sort -t - -k 2n -k 3n -k 4n -k 5n
}

Example: getrevs views.module

NOTE: Sometimes this doesn't work and nothing is displayed. I tried it out once with cck and for whatever reason the releases weren't listed.

Update Your Module to the Latest Stable Release

Not a whole lot of time saving here, but based on the previous revision list, choose one and update your (currently) HEAD version with something a bit more stable.

# Do a cvs update using the specified revision
updatemod()
{
cvs up -dP -r "${1}"
}

Example: updatemod DRUPAL-1--1-0

Kudos to Matt Petrowsky from gotdrupal.com for these.

Hey Patrick, Thanks for the

Hey Patrick,

Thanks for the kudos on my profile functions. I haven't even updated my own site with this, but here's an improved version of the revisions function.


# Grabs the revisions from CVS log and sorts them proper
drevs()
{
cvs log "${1}" | egrep 'DRUPAL-.*:' | sort -t - -k 2n -k 3n -k 4n -k 5n
}

I got tired of hunting through the list of revision tags and decided to take the 5-10 minutes to apply the proper sorting flags to the sort command. This puts the latest and greatest towards the bottom and sorting now puts 10 after 1 instead of before. ;)

Enjoy! Matt Petrowsky - GotDrupal.com

Nice Matt! I'll give it a

Nice Matt! I'll give it a try. We'll be posting a really slick script that automates a ton more as well... will keep you updated.

Patrick

Example: getrevs

Example: getrevs views.module

NOTE: Sometimes this doesn't work and nothing is displayed. I tried it out once with cck and for whatever reason the releases weren't listed.

Sometimes the name of the module doesn’t match the name of its project. With CCK, there’s no cck.module; it’s called content.module.

We've noticed this as well.

We've noticed this as well. Since this post we've migrated toward Drush, which does a great job of automatically checking out the latest version of a given module. You can also override the defaults if you want to specify a specific release.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <h1> <h2> <h3> <h4> <h5> <h6>
  • Lines and paragraphs break automatically.

More information about formatting options