function drush_pm_inject_info_file_metadata

8.0.x drush_pm_inject_info_file_metadata($project_dir, $project_name, $version, $datestamp)
6.x drush_pm_inject_info_file_metadata($project_dir, $project_name, $version)
7.x drush_pm_inject_info_file_metadata($project_dir, $project_name, $version, $datestamp)
5.x drush_pm_inject_info_file_metadata($project_dir, $project_name, $version)
master drush_pm_inject_info_file_metadata($project_dir, $project_name, $version, $datestamp)

Inject metadata into all .info files for a given project.


string $project_dir: The full path to the root directory of the project to operate on.

string $project_name: The project machine name (AKA shortname).

string $version: The version string to inject into the .info file(s).

Return value

boolean TRUE on success, FALSE on any failures appending data to .info files.

2 calls to drush_pm_inject_info_file_metadata()
DrushMakeProject::processGitInfoFiles in commands/make/
Process info files when downloading things from git.
package_handler_post_download in commands/pm/package_handler/
Post download action.


commands/pm/, line 1850
The drush Project Manager


function drush_pm_inject_info_file_metadata($project_dir, $project_name, $version) {
  $info_files = drush_scan_directory($project_dir, '/.*\.info$/');
  if (!empty($info_files)) {
    // Construct the string of metadata to append to all the .info files.
    // Taken straight from:
    $info = "\n\n; Information added by drush on " . date('Y-m-d') . "\n";
    $info .= "version = \"$version\"\n";
    // .info files started with 5.x, so we don't have to worry about version
    // strings like "4.7.x-1.0" in this regular expression. If we can't parse
    // the version (also from an old "HEAD" release), or the version isn't at
    // least 6.x, don't add any "core" attribute at all.
    $matches = array();
    if (preg_match('/^((\d+)\.x)-.*/', $version, $matches) && $matches[2] >= 6) {
      $info .= "core = \"$matches[1]\"\n";
    $info .= "project = \"$project_name\"\n";
    $info .= 'datestamp = "' . time() . "\"\n";
    $info .= "\n";
    foreach ($info_files as $info_file) {
      if (!drush_file_append_data($info_file->filename, $info)) {
        return FALSE;
  return TRUE;