Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Plugin/Patches.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ public function activate(Composer $composer, IOInterface $io): void
'type' => 'string',
'default' => 'patches.json',
],
'patch-files' => [
'type' => 'list',
'default' => [],
],
"ignore-dependency-patches" => [
'type' => 'list',
'default' => [],
Expand Down
30 changes: 17 additions & 13 deletions src/Resolver/PatchesFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,26 @@ class PatchesFile extends ResolverBase
*/
public function resolve(PatchCollection $collection): void
{
$patches_file_path = $this->plugin->getConfig('patches-file');
$valid_patches_file = file_exists(realpath($patches_file_path)) && is_readable(realpath($patches_file_path));

// If we don't have a valid patches file, exit early.
if (!$valid_patches_file) {
return;
$patch_files = $this->plugin->getConfig('patch-files');
if ($patches_file_path = $this->plugin->getConfig('patches-file')) {
$patch_files[] = $patches_file_path;
$this->io->write('<warning>`patches-file` config key is deprecated. Use patch-files list instead.</warning>');
}
foreach ($patch_files as $patch_file) {
if (!file_exists(realpath($patch_file)) && !is_readable(realpath($patch_file))) {
$this->io->write("<warning>Patches file '$patch_file' is not readable.</warning>");
continue;
}

$this->io->write(' - <info>Resolving patches from patches file.</info>');
$patches_file = $this->readPatchesFile($patches_file_path);
$this->io->write(" - <info>Resolving patches from patches file '$patch_file'.</info>");
$patches_file = $this->readPatchesFile($patch_file);

foreach ($this->findPatchesInJson($patches_file) as $package => $patches) {
foreach ($patches as $patch) {
/** @var Patch $patch */
$patch->extra['provenance'] = "patches-file:" . $patches_file_path;
$collection->addPatch($patch);
foreach ($this->findPatchesInJson($patches_file) as $package => $patches) {
foreach ($patches as $patch) {
/** @var Patch $patch */
$patch->extra['provenance'] = "patches-file:" . $patch_file;
$collection->addPatch($patch);
}
}
}
}
Expand Down