Skip to content

Commit 4ce967d

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 5d43604 commit 4ce967d

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
@@ -350,7 +350,7 @@ public function postInstall(PackageEvent $event)
350350
$patch->url = $providing_install_path.'/'.$patch->url;
351351
}
352352

353-
$this->getAndApplyPatch($downloader, $install_path, $patch->url);
353+
$this->getAndApplyPatch($downloader, $install_path, $patch->url, $package);
354354
$this->eventDispatcher->dispatch(
355355
null,
356356
new PatchEvent(PatchEvents::POST_PATCH_APPLY, $package, $patch->url, $patch->description)
@@ -396,9 +396,10 @@ protected function getPackageFromOperation(OperationInterface $operation)
396396
* @param RemoteFilesystem $downloader
397397
* @param $install_path
398398
* @param $patch_url
399+
* @param PackageInterface $package
399400
* @throws \Exception
400401
*/
401-
protected function getAndApplyPatch(RemoteFilesystem $downloader, $install_path, $patch_url)
402+
protected function getAndApplyPatch(RemoteFilesystem $downloader, $install_path, $patch_url, PackageInterface $package)
402403
{
403404

404405
// Local patch file.
@@ -418,6 +419,11 @@ protected function getAndApplyPatch(RemoteFilesystem $downloader, $install_path,
418419
// it might be useful. p4 is useful for Magento 2 patches
419420
$patch_levels = $this->getConfig('patch-levels');
420421

422+
// Check for specified patch level for this package.
423+
if (!empty($this->composer->getPackage()->getExtra()['patchLevel'][$package->getName()])){
424+
$patch_levels = array($this->composer->getPackage()->getExtra()['patchLevel'][$package->getName()]);
425+
}
426+
421427
// Attempt to apply with git apply
422428
$patched = $this->applyPatchWithGit($install_path, $patch_levels, $filename);
423429

0 commit comments

Comments
 (0)