You are here

public function RoboFile::diff in Panopoly 7

Makes a diff of a single module which can be used in a child distro.

@option bool $uncommitted Uncommitted changes

Parameters

string $module: The module to make a diff of (ex. panopoly_search)

File

./RoboFile.php, line 313

Class

RoboFile
This is project's console commands configuration for Robo task runner.

Code

public function diff($module, $opts = [
  'uncommitted' => FALSE,
]) {
  $diff_spec = '';
  if (!$opts['uncommitted']) {
    $diff_spec = static::PANOPOLY_DEFAULT_BRANCH . '..';
  }
  $module_path = __DIR__ . "/modules/panopoly/{$module}";
  $output = $this
    ->runProcess("git diff {$diff_spec} -- {$module_path}")
    ->getOutput();
  $output = preg_replace("|^diff --git a/modules/panopoly/{$module}/(.*?) b/modules/panopoly/{$module}/(.*?)\$|m", 'diff --git a/\\1 b/\\2', $output);
  $output = preg_replace("|^--- a/modules/panopoly/{$module}/(.*?)\$|m", '--- a/\\1', $output);
  $output = preg_replace("|^\\+\\+\\+ b/modules/panopoly/{$module}/(.*?)\$|m", '+++ b/\\1', $output);
  print $output;
}