You are here

function drush_hacked_diff in Hacked! 6

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

Drush command 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.

File

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

Code

function drush_hacked_diff($short_name = '') {
  $project = hacked_project_load($short_name);
  if (!$project) {
    return drush_set_error('HACKED_PROJECT_NOT_FOUND', dt('Could not find project: !project', array(
      '!project' => $short_name,
    )));
  }
  $local_location = realpath(hacked_find_local_project_directory($project));
  $clean_location = hacked_download_release($this_release['download_link'], $project['project_type'], $project['short_name'], $project['existing_version']);

  // More special handling for core:
  if ($project['type'] != 'core') {
    $clean_location = $clean_location . "/{$project['short_name']}";
  }
  else {
    $clean_location = $clean_location . "/{$project['short_name']}-{$project['version']}";
  }
  $clean_location = realpath($clean_location);
  drush_shell_exec("diff -upr {$clean_location} {$local_location}");
  $lines = drush_shell_exec_output();
  $local_location_trim = dirname($local_location . '/dummy.file') . '/';
  $clean_location_trim = dirname($clean_location . '/dummy.file') . '/';
  foreach ($lines as $line) {
    if (strpos($line, '+++') === 0) {
      $line = str_replace($local_location_trim, '', $line);
    }
    if (strpos($line, '---') === 0) {
      $line = str_replace($clean_location_trim, '', $line);
    }
    if (strpos($line, 'diff -upr') === 0) {
      $line = str_replace($clean_location_trim, 'old/', $line);
      $line = str_replace($local_location_trim, 'new/', $line);
    }
    drush_print($line);
  }
}