Illustration of Yeti character writing with a pencil.

Contribulations

Profile picture for user Rob
Rob Bayliss
CTO

Understanding the Drupal project system (Prezi Presentation)

Using git to fetch a drupal project

  • Make sure you have git installed. If you don’t have it, you can work from a snapshot release and use your own version control to generate diffs of changes, but there’s no guarantees that the release is up to date.
  • When viewing a project page, click on the version control tab.
  • Select the appropriate branch and follow the instructions for setting up the repository for the first time.

If you are using git for version control on your project, you can still grab individual projects straight from the drupal.org repository, but you’ll need to use submodules, which are beyond the scope of this presentation.

Generating a patch for drupal.org using git

  • When your changes are ready for submission, you can review them by changing directory into the project folder and typing git diff.
  • To put this into a patch that others can apply, use the following command: git diff > [description]-[issue-number]-[comment-number].patch. Description should be a 3-4 word description of your patch. Issue number comes from the issue you are submitting the patch to, and comment number can be found to the left of the reply form on the issue.
  • Review the patch one more time before you submit it, paying special attention that there you haven’t added anything accidentally, like your settings.php file.
  • Submit to the issue queue with a comment describing what your patch does, and change the issue status to “Needs Review.”

What to expect from your contribution

It’s pretty rare that a patch actually gets accepted the first time around (especially with major projects), so be prepared for a couple rounds of refactoring before your feature or bugfix is integrated into the module. If the patch is ignored or rejected (this happens occasionally), there’s not much you can do, but at least it will be easier to apply the fix in the future, since it is publicly searchable on drupal.org.

Extra Credit

Some things you can do to increase your contribution-karma in the community:

  • Write Simpletests for your patches. This may be required for contributions to certain projects (core included).
  • Review other people’s patches. Try to duplicate the issue without the patch, apply the patch and check that it’s fixed and also that nothing else has broken.
  • Fix documentation errors wherever you find them. This is pretty easy, but if you spot a problem while browsing on api.drupal.org, that code is generated from the comments (docblocks) for each function. You can submit a patch to fix it and instantly become a core contributor.

Resources:

Coding Standards Contributions Home Patch Review Handbook Page