Commit 9df4b5fd authored by Dmitri Gaskin's avatar Dmitri Gaskin
Browse files

#745224 by jhedstrom, q0rban, Steven Jones, glennpratt: Fixed Apply patches...

#745224 by jhedstrom, q0rban, Steven Jones, glennpratt: Fixed Apply patches from git diff and git format-patch.
parent 27f74538
Loading
Loading
Loading
Loading
+34 −2
Changes for drush_make.project.inc: 34 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -106,14 +106,47 @@ class DrushMakeProject {
      }
      // Download the patch.
      if ($filename = _drush_make_download_file($info)) {
        $patched = FALSE;
        $output = '';
        // Test each patch style; -p1 is the default with git. See
        // http://drupal.org/node/1054616
        $patch_levels = array('-p1', '-p0');
        foreach ($patch_levels as $patch_level) {
          $checked = drush_shell_exec('cd %s && GIT_WORK_TREE=. git apply --check %s %s --verbose', $project_directory, $patch_level, $filename);
          if ($checked) {
            // Apply the first successful style.
            $patched = drush_shell_exec('cd %s && GIT_WORK_TREE=. git apply %s %s --verbose', $project_directory, $patch_level, $filename);
            break;
          }
        }

        // In some rare cases, git will fail to apply a patch, fallback to using
        // the 'patch -p0' command.
        if (!$patched) {
          $patched = drush_shell_exec("patch -p0 -d %s < %s", $project_directory, $filename);
        }

        if ($output = drush_shell_exec_output()) {
          // Log any command output, visible only in --verbose or --debug mode.
          drush_log(implode("\n", $output));
        }

        // Set up string placeholders to pass to dt().
        $dt_args = array(
          '@name' => $this->name,
          '@filename' => basename($filename),
        );

        if ($patched) {
          if (!$ignore_checksums && !_drush_make_verify_checksums($info, $filename)) {
             return FALSE;
          }
          $patches_txt .= '- ' . $info['url'] . "\n";
          drush_log(dt('@name patched with @filename.', $dt_args), 'ok');
        }
        else {
          drush_log(dt("Unable to patch @name with @filename.", $dt_args), 'error');
        }
        drush_log($this->name . ' patched with ' . basename($filename) . '.', $patched ? 'ok' : 'error');
        drush_op('unlink', $filename);
      }
      else {
@@ -357,4 +390,3 @@ class DrushMakeProject_Translation extends DrushMakeProject {
    }
  }
}
+2 −2
Changes for drush_make.test.inc: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -69,7 +69,7 @@ function drush_make_test_get_tests($id = NULL) {
      'makefile' => 'tests/patches.make',
      'build'    => TRUE,
      'messages' => array(
        'Build hash: 24f14f6e28498678cebcab2cff3e1030',
        'Build hash: e2d38e343c7e95b994443c34ec665a23',
      ),
      'options'  => array('no-core' => TRUE, 'no-patch-txt' => TRUE),
    ),
@@ -78,7 +78,7 @@ function drush_make_test_get_tests($id = NULL) {
      'makefile' => 'tests/patches.make',
      'build'    => TRUE,
      'messages' => array(
        'Build hash: 173ae5e2120463e31ff2e2a9cc02491b',
        'Build hash: c17e8b59055db741778f9048bf289332',
      ),
      'options'  => array('no-core' => TRUE),
    ),
+1 −1
Changes for tests/patches.make: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -4,4 +4,4 @@ api = 2
; Test that patches work
projects[token][version] = 1.13
projects[token][patch][] = http://drupal.org/files/issues/new_role_email_action5.patch
projects[token][patch][] = http://drupal.org/files/issues/token_module_array_resolution_587148_01.patch
 No newline at end of file
projects[token][patch][] = http://drupal.org/files/issues/587148-token-check-duplicate-tokens.patch