You are here

function drush_hacked_details in Hacked! 8.2

Same name and namespace in other branches
  1. 5 hacked.drush.inc \drush_hacked_details()
  2. 6.2 hacked.drush.inc \drush_hacked_details()
  3. 6 hacked.drush.inc \drush_hacked_details()
  4. 7.2 hacked.drush.inc \drush_hacked_details()

Drush callback that shows the list of changes/unchanged files in a project.

You may specify the --include-unchanged option to show unchanged files too, otherwise just the changed and deleted files are shown.

Parameters

string $short_name: The project short name.

File

./hacked.drush.inc, line 298
Hacked drush command.

Code

function drush_hacked_details($short_name) {
  $project = new hackedProject($short_name);
  $report = $project
    ->compute_details();
  drush_print(dt('Details for project: @name', [
    '@name' => $project
      ->title(),
  ]));
  drush_print(dt('Total files: @total_files, files changed: @changed_files, deleted files: @deleted_files', [
    '@total_files' => count($report['files']),
    '@changed_files' => $report['counts']['different'],
    '@deleted_files' => $report['counts']['missing'],
  ]));
  drush_print('');
  drush_print(dt('Detailed results:'));

  // Sort the results:
  arsort($report['files']);
  $rows[] = [
    dt('Status'),
    dt('File'),
  ];
  $show_unchanged = drush_get_option('include-unchanged', FALSE);
  foreach ($report['files'] as $file => $status) {
    if (!$show_unchanged && $status == HACKED_STATUS_UNHACKED) {
      continue;
    }
    $row = [];

    // Now add the status:
    switch ($status) {
      case HACKED_STATUS_UNHACKED:
        $row[] = dt('Unchanged');
        break;
      case HACKED_STATUS_HACKED:
        $row[] = t('Changed');
        break;
      case HACKED_STATUS_DELETED:
        $row[] = t('Deleted');
        break;
      case HACKED_STATUS_UNCHECKED:
      default:
        $row[] = t('Unchecked');
        break;
    }
    $row[] = $file;
    $rows[] = $row;
  }
  drush_print_table($rows, TRUE);
}