Skip to content

Commit

Permalink
Allows patch-level to be specified per-project.
Browse files Browse the repository at this point in the history
- Backport to `1.x`
- Reroll of cweagans#101
- Fixes cweagans#43
  • Loading branch information
jhedstrom authored and stucki committed Sep 14, 2021
1 parent 5d43604 commit 4ce967d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Plugin/Patches.php
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ public function postInstall(PackageEvent $event)
$patch->url = $providing_install_path.'/'.$patch->url;
}

$this->getAndApplyPatch($downloader, $install_path, $patch->url);
$this->getAndApplyPatch($downloader, $install_path, $patch->url, $package);
$this->eventDispatcher->dispatch(
null,
new PatchEvent(PatchEvents::POST_PATCH_APPLY, $package, $patch->url, $patch->description)
Expand Down Expand Up @@ -396,9 +396,10 @@ protected function getPackageFromOperation(OperationInterface $operation)
* @param RemoteFilesystem $downloader
* @param $install_path
* @param $patch_url
* @param PackageInterface $package
* @throws \Exception
*/
protected function getAndApplyPatch(RemoteFilesystem $downloader, $install_path, $patch_url)
protected function getAndApplyPatch(RemoteFilesystem $downloader, $install_path, $patch_url, PackageInterface $package)
{

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

// Check for specified patch level for this package.
if (!empty($this->composer->getPackage()->getExtra()['patchLevel'][$package->getName()])){
$patch_levels = array($this->composer->getPackage()->getExtra()['patchLevel'][$package->getName()]);
}

// Attempt to apply with git apply
$patched = $this->applyPatchWithGit($install_path, $patch_levels, $filename);

Expand Down

0 comments on commit 4ce967d

Please sign in to comment.