Header comment blocks

Last modified: October 25, 2008 - 08:13

All Drupal source code files should start with a header containing the RCS $Id$ keyword:

<?php
// $Id: CODING_STANDARDS,v 1.1 2001/11/05 07:32:17 natrak Exp $

If you add a new file to CVS, just write
<?php
// $Id$

Copy this line 1:1. Please note that

  • The CVS Id tag should always be on the first line of all files (for PHP files, it's actually the second line).
  • Everything after the starting $Id and before the closing $ is automatically replaced with the accurate values by CVS every time you checkout or update a workspace. You shouldn't edit this manually, and you never have to worry about changes to this line causing conflicts when you commit.
  • CVS Id tags are case-sensitive.
  • You must not add a space between $Id and $ when you commit the keyword for the first time.

Other files

CSS files
should contain the CVS Id tag on the first line using a valid CSS comment:
/* $Id$ */

Be careful, because using a invalid or no comment syntax might break the whole stylesheet in some browsers.
JavaScript files
should contain the CVS Id tag on the first line using a JS inline comment:
// $Id$

.info files
should contain the CVS Id tag on the first line, preceded by a semicolon:
; $Id$

Text files
like README.txt and CHANGELOG.txt should contain the CVS Id tag on the first line using one of the following styles:
/* $Id$ */
# $Id$

Note that if your local copy does not expand these keywords, it's entirely possible that either your CVS client is misconfigured, or that someone with a misconfigured CVS client checked in the files with a flag that disables the keyword substitution. You can use cvs status and look for the "Sticky Options:" line. If you see -ko or -kb it means that keyword expansion is disabled on that file. If so, you can then run cvs admin -kkv [filename] to enable normal keyword expansion again. If you're using a CVS GUI, figuring out how to specify this flag in your GUI's configuration is left as an exercise for the interested reader.

 
 

Drupal is a registered trademark of Dries Buytaert.