function drush_pm_inject_info_file_metadata

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

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

Parameters

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).

int $datestamp: The datestamp of the last commit.

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/make.project.inc
Process info files when downloading things from git.
package_handler_post_download in commands/pm/package_handler/git_drupalorg.inc
Post download action.

File

commands/pm/pm.drush.inc, line 2216
The drush Project Manager

Code

function drush_pm_inject_info_file_metadata($project_dir, $project_name, $version, $datestamp) {
  // `drush_drupal_major_version()` cannot be used here because this may be running
  // outside of a Drupal context.
  $yaml_format = substr($version, 0, 1) >= 8;
  $pattern = preg_quote($yaml_format ? '.info.yml' : '.info');
  $info_files = drush_scan_directory($project_dir, '/.*' . $pattern . '$/');
  if (!empty($info_files)) {
    // Construct the string of metadata to append to all the .info files.
    if ($yaml_format) {
      $info = _drush_pm_generate_info_yaml_metadata($version, $project_name);
    }
    else {
      $info = _drush_pm_generate_info_ini_metadata($version, $project_name, $datestamp);
    }
    foreach ($info_files as $info_file) {
      if (!drush_file_append_data($info_file->filename, $info)) {
        return FALSE;
      }
    }
  }
  return TRUE;
}