Skip to content

Commit

Permalink
Merge pull request #189 from jhedstrom/patch-level-1-x
Browse files Browse the repository at this point in the history
1.x backport: Allows patch-level to be specified per-project.
  • Loading branch information
cweagans committed May 11, 2018
2 parents a4d6dc0 + 49dbb8f commit 2ec4f00
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Patches.php
Expand Up @@ -310,7 +310,7 @@ public function postInstall(PackageEvent $event) {
$this->io->write(' <info>' . $url . '</info> (<comment>' . $description. '</comment>)');
try {
$this->eventDispatcher->dispatch(NULL, new PatchEvent(PatchEvents::PRE_PATCH_APPLY, $package, $url, $description));
$this->getAndApplyPatch($downloader, $install_path, $url);
$this->getAndApplyPatch($downloader, $install_path, $url, $package);
$this->eventDispatcher->dispatch(NULL, new PatchEvent(PatchEvents::POST_PATCH_APPLY, $package, $url, $description));
$extra['patches_applied'][$description] = $url;
}
Expand Down Expand Up @@ -354,9 +354,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.
if (file_exists($patch_url)) {
Expand All @@ -376,6 +377,10 @@ 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');

// 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 2ec4f00

Please sign in to comment.