How to Win Friends and Influence Drupal: A guide to patch review

Time: 
Oct 4 2008 1:30pm
Speaker: 
webchick
Skill Level: 
Intermediate
Location: 
Area C

This session walked through how to create, apply, and review patches, using *real* issues from the Drupal 7 queue.

Plan

  • Introduction to the Drupal community
  • How do I commit changes
  • How to contribute my own modules
  • How to get involved in core development

Did you know?

  • 800 people contribute to core at various levels
  • The peer review cycle will optimize your contribution

How to get started / Philosophy

  • Just jump in and find something to do to win brownie points
  • Show that you've made an effort before asking your question
  • Get CVS access -- http://drupal.org/node/59

    • your code must be visible
    • have your own module
    • no duplicated feature
    • extra points if you're into patches, themes or translations
  • Submit a patch to a module before creating a new one
  • Taking over abandonned modules - http://drupal.org/node/251466

Checking out Drupal from cvs

cvs 
        -z6     # enables compression
        -d:pserver:<YOUR ACCOUNT>@cvs.drupal.org:/cvs/REPOSITORY
        co # checkout
        -r <TAG>

        -d <DESTINATION>
        -D <DATE>
        <TARGET>

<YOUR ACCOUNT> :: anonymous:anonymous | <DRUPAL USERNAME>:<DRUPAL PASSWORD>

<REPOSITORY> :: drupal | drupal-contrib
<TAG> :: HEAD | DRUPAL-5-7 | DRUPAL-6 | DRUPAL-6-1
<DESTINATION> :: a local folder
<DATE> :: a date
<TARGET> :: drupal | contributions/modules/MODULE | contributions/themes/THEME | contributions/translations/TRANSLATION | contributions/profiles/PROFILE

        -l      # only checkout directory, not the modules themselves

Checkout as anonymous if you just want to maintain your site from CVS

Adding new modules

cvs add module-name
cvs commit -m " #<issue ID> by <your username> Comment about commit"

Tagging and branching

  • A branch is a Drupal version
  • A tag is a point in time of a Drupal version
cvs tag -b DRUPAL-6--2 modules/mymodule

To create an official release

cvs tag -b DRUPAL-6--2 modules/mymodule

Checking for updates

cvs update -dP -r DRUPAL-5

How a patch is done

  • First thing to do when you get a problem you're not responsible for : check the issues queue on http://drupal.org/project/issues/ page -- there might already be a patch

  • Remember: users read forums; developers read the issue queue
  • Install wget or curl, cvs, patch and -- diff http://drupal.org/node/320

  • Download patch: wget <patch file>

  • Patch file against current file: patch -p0 < dst.patch

  • HUNK failures means the patch doesn't apply to the file
  • FUZZ means I didn't find target string but I got something similar
  • Revert a badly patched file: cvs -dPC
  • If patch is missing, you may add an issue
  • Create a patch against last checked out version: cvs diff -up > drupal-<version>-<description>-<node ID>-<comment ID>.patch

  • Place your patch in patch directory
  • Submit patch to drupal.org with a "code needs review" status
  • Review other people's patches

Your Drupal user account

  • Log in on Drupal.org and check your options
  • CVS Logs allows you to take a look a projects before they have a page

rsyncing Drupal.org

http://drupal.org/node/277268

  • grep command is useful to search through whole Drupal code base