function drush_pm_releases

8.0.x pm.drush.inc drush_pm_releases()
6.x pm.drush.inc drush_pm_releases()
7.x pm.drush.inc drush_pm_releases()
3.x pm.drush.inc drush_pm_releases()
4.x pm.drush.inc drush_pm_releases()
5.x pm.drush.inc drush_pm_releases()
master pm.drush.inc drush_pm_releases()

A drush command callback. Show release info for given project(s).

File

commands/pm/pm.drush.inc, line 818
The drush Package Manager

Code

function drush_pm_releases() {
  // We don't provide for other options here, so we supply an explicit path.
  drush_include_engine('update_info', 'drupal', NULL, DRUSH_BASE_PATH . '/commands/pm/update_info');

  $projects = func_get_args();
  $projects = drupal_map_assoc($projects);
  $info = pm_get_project_info($projects);
  $project_info = drush_get_projects();

  $rows[] = array(dt('Project'), dt('Release'), dt('Date'), dt('Status'));
  foreach ($info as $key => $project) {
    $recommended = isset($project['recommended_major']) ? $project['recommended_major'] : NULL;
    $supported = isset($project['supported_majors']) ? explode(',', $project['supported_majors']) : array();
    $default = $project['default_major'];
    $recommended_version = NULL;
    $latest_version = NULL;
    foreach ($project['releases'] as $release) {
      if ($release['version_major'] == $recommended) {
        if (!isset($latest_version)) {
          $latest_version = $release['version'];
        }
        if (empty($release['version_extra'])) {
          if (!isset($recommended_version)) {
            $recommended_version = $release['version'];
          }
        }
      }
    }
    if (!isset($recommended_version)) {
      $recommended_version = $latest_version;
    }
    foreach ($project['releases'] as $release) {
      $status = array();
      $type = array();
      if (($k = array_search($release['version_major'], $supported)) !== FALSE) {
        $status[] = dt('Supported');
        unset($supported[$k]);
      }
      if ((isset($recommended_version)) && ($release['version'] == $recommended_version)) {
        $status[] = dt('Recommended');
      }
      if ($release['version_extra'] == 'dev') {
        $status[] = dt('Development');
      }
      if (isset($project_info[$key])) {
        if ($project_info[$key]->info['version'] == $release['version']) {
          $status[] = dt('Installed');
        }
      }
      if (isset($release['terms']) && array_key_exists('Release type', $release['terms'])) {
        foreach ($release['terms']['Release type'] as $one_type) {
          if ($one_type == 'Security update') {
            $status[] = dt('Security');
          }
        }
      }
      $rows[] = array(
        $key,
        $release['version'],
        format_date($release['date'], 'custom', 'Y-M-d'),
        implode(', ', $status),
      );
    }
  }

  if (count($rows) == 1) {
    return drush_set_error('DRUSH_PM_PROJECT_NOT_FOUND', dt('No information available.'));
  }
  else {
    return drush_print_table($rows, TRUE);
  }
}