Skip to content

Commit 67ccdeb

Browse files
committed
Allows patch-level to be specified per-project.
- Reroll of cweagans#101 - Fixes cweagans#43
1 parent 462e650 commit 67ccdeb

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/Patches.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ public function postInstall(PackageEvent $event) {
300300
$this->io->write(' <info>' . $url . '</info> (<comment>' . $description. '</comment>)');
301301
try {
302302
$this->eventDispatcher->dispatch(NULL, new PatchEvent(PatchEvents::PRE_PATCH_APPLY, $package, $url, $description));
303-
$this->getAndApplyPatch($downloader, $install_path, $url);
303+
$this->getAndApplyPatch($downloader, $install_path, $url, $package);
304304
$this->eventDispatcher->dispatch(NULL, new PatchEvent(PatchEvents::POST_PATCH_APPLY, $package, $url, $description));
305305
$extra['patches_applied'][$description] = $url;
306306
}
@@ -344,9 +344,10 @@ protected function getPackageFromOperation(OperationInterface $operation) {
344344
* @param RemoteFilesystem $downloader
345345
* @param $install_path
346346
* @param $patch_url
347+
* @param PackageInterface $package
347348
* @throws \Exception
348349
*/
349-
protected function getAndApplyPatch(RemoteFilesystem $downloader, $install_path, $patch_url) {
350+
protected function getAndApplyPatch(RemoteFilesystem $downloader, $install_path, $patch_url, PackageInterface $package) {
350351

351352
// Local patch file.
352353
if (file_exists($patch_url)) {
@@ -366,6 +367,11 @@ protected function getAndApplyPatch(RemoteFilesystem $downloader, $install_path,
366367
// it might be useful. p4 is useful for Magento 2 patches
367368
$patch_levels = array('-p1', '-p0', '-p2', '-p4');
368369

370+
// Check for specified patch level for this package.
371+
if (!empty($this->composer->getPackage()->getExtra()['patchLevel'][$package->getName()])) {
372+
$patch_levels = array($this->composer->getPackage()->getExtra()['patchLevel'][$package->getName()]);
373+
}
374+
369375
// Attempt to apply with git apply.
370376
$patched = $this->applyPatchWithGit($install_path, $patch_levels, $filename);
371377

0 commit comments

Comments
 (0)