Skip to content

Commit 0b78f98

Browse files
jhedstromstucki
authored andcommitted
Allows patch-level to be specified per-project.
- Backport to `1.x` - Reroll of cweagans#101 - Fixes cweagans#43
1 parent 3dafd72 commit 0b78f98

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/Plugin/Patches.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ public function postInstall(PackageEvent $event)
355355
$patch->url = $providing_install_path.'/'.$patch->url;
356356
}
357357

358-
$this->getAndApplyPatch($downloader, $install_path, $patch->url);
358+
$this->getAndApplyPatch($downloader, $install_path, $patch->url, $package);
359359
$this->eventDispatcher->dispatch(
360360
null,
361361
new PatchEvent(PatchEvents::POST_PATCH_APPLY, $package, $patch->url, $patch->description)
@@ -401,9 +401,10 @@ protected function getPackageFromOperation(OperationInterface $operation)
401401
* @param RemoteFilesystem $downloader
402402
* @param $install_path
403403
* @param $patch_url
404+
* @param PackageInterface $package
404405
* @throws \Exception
405406
*/
406-
protected function getAndApplyPatch(RemoteFilesystem $downloader, $install_path, $patch_url)
407+
protected function getAndApplyPatch(RemoteFilesystem $downloader, $install_path, $patch_url, PackageInterface $package)
407408
{
408409

409410
// Local patch file.
@@ -430,6 +431,11 @@ protected function getAndApplyPatch(RemoteFilesystem $downloader, $install_path,
430431
// it might be useful. p4 is useful for Magento 2 patches
431432
$patch_levels = $this->getConfig('patch-levels');
432433

434+
// Check for specified patch level for this package.
435+
if (!empty($this->composer->getPackage()->getExtra()['patchLevel'][$package->getName()])){
436+
$patch_levels = array($this->composer->getPackage()->getExtra()['patchLevel'][$package->getName()]);
437+
}
438+
433439
// Attempt to apply with git apply
434440
$patched = $this->applyPatchWithGit($install_path, $patch_levels, $filename);
435441

0 commit comments

Comments
 (0)