Skip to content

Commit

Permalink
Merge pull request #165 from danepowell/issue-148
Browse files Browse the repository at this point in the history
Fixes #148: Incompatible with Git 2.14+.
  • Loading branch information
cweagans committed Nov 22, 2017
2 parents 6440b5a + 8c8c356 commit 3466175
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/Patches.php
Original file line number Diff line number Diff line change
Expand Up @@ -386,16 +386,28 @@ protected function getAndApplyPatch(RemoteFilesystem $downloader, $install_path,
// it might be useful. p4 is useful for Magento 2 patches
$patch_levels = array('-p1', '-p0', '-p2', '-p4');
foreach ($patch_levels as $patch_level) {
if ($this->io->isVerbose()) {
$comment = 'Testing ability to patch with git apply.';
$comment .= ' This command may produce errors that can be safely ignored.';
$this->io->write('<comment>' . $comment . '</comment>');
}
$checked = $this->executeCommand(
'cd %s && git --git-dir=. apply --check %s %s',
'git -C %s apply --check -v %s %s',
$install_path,
$patch_level,
$filename
);
$output = $this->executor->getErrorOutput();
if (substr($output, 0, 7) == 'Skipped') {
// Git will indicate success but silently skip patches in some scenarios.
//
// @see https://github.com/cweagans/composer-patches/pull/165
$checked = false;
}
if ($checked) {
// Apply the first successful style.
$patched = $this->executeCommand(
'cd %s && git --git-dir=. apply %s %s',
'git -C %s apply %s %s',
$install_path,
$patch_level,
$filename
Expand Down

0 comments on commit 3466175

Please sign in to comment.