Skip to content
Snippets Groups Projects
Unverified Commit 8322ffc7 authored by briancanini's avatar briancanini Committed by GitHub
Browse files

Merge pull request #598 from ASCWebServices/dependencies

Upgrading cweagans/composer-patches (1.7.0 => 1.7.3)
parents d72c4eac f96e8117
No related branches found
No related tags found
No related merge requests found
......@@ -999,16 +999,16 @@
},
{
"name": "cweagans/composer-patches",
"version": "1.7.0",
"version": "1.7.3",
"source": {
"type": "git",
"url": "https://github.com/cweagans/composer-patches.git",
"reference": "ae02121445ad75f4eaff800cc532b5e6233e2ddf"
"reference": "e190d4466fe2b103a55467dfa83fc2fecfcaf2db"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/cweagans/composer-patches/zipball/ae02121445ad75f4eaff800cc532b5e6233e2ddf",
"reference": "ae02121445ad75f4eaff800cc532b5e6233e2ddf",
"url": "https://api.github.com/repos/cweagans/composer-patches/zipball/e190d4466fe2b103a55467dfa83fc2fecfcaf2db",
"reference": "e190d4466fe2b103a55467dfa83fc2fecfcaf2db",
"shasum": ""
},
"require": {
......@@ -1041,9 +1041,9 @@
"description": "Provides a way to patch Composer packages.",
"support": {
"issues": "https://github.com/cweagans/composer-patches/issues",
"source": "https://github.com/cweagans/composer-patches/tree/1.7.0"
"source": "https://github.com/cweagans/composer-patches/tree/1.7.3"
},
"time": "2020-09-30T17:56:20+00:00"
"time": "2022-12-20T22:53:13+00:00"
},
{
"name": "desandro/imagesloaded",
......
......@@ -1033,17 +1033,17 @@
},
{
"name": "cweagans/composer-patches",
"version": "1.7.0",
"version_normalized": "1.7.0.0",
"version": "1.7.3",
"version_normalized": "1.7.3.0",
"source": {
"type": "git",
"url": "https://github.com/cweagans/composer-patches.git",
"reference": "ae02121445ad75f4eaff800cc532b5e6233e2ddf"
"reference": "e190d4466fe2b103a55467dfa83fc2fecfcaf2db"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/cweagans/composer-patches/zipball/ae02121445ad75f4eaff800cc532b5e6233e2ddf",
"reference": "ae02121445ad75f4eaff800cc532b5e6233e2ddf",
"url": "https://api.github.com/repos/cweagans/composer-patches/zipball/e190d4466fe2b103a55467dfa83fc2fecfcaf2db",
"reference": "e190d4466fe2b103a55467dfa83fc2fecfcaf2db",
"shasum": ""
},
"require": {
......@@ -1054,7 +1054,7 @@
"composer/composer": "~1.0 || ~2.0",
"phpunit/phpunit": "~4.6"
},
"time": "2020-09-30T17:56:20+00:00",
"time": "2022-12-20T22:53:13+00:00",
"type": "composer-plugin",
"extra": {
"class": "cweagans\\Composer\\Patches"
......@@ -1076,6 +1076,10 @@
}
],
"description": "Provides a way to patch Composer packages.",
"support": {
"issues": "https://github.com/cweagans/composer-patches/issues",
"source": "https://github.com/cweagans/composer-patches/tree/1.7.3"
},
"install-path": "../cweagans/composer-patches"
},
{
......
......@@ -3,7 +3,7 @@
'name' => 'osu-asc-webservices/d8-upstream',
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => 'a904cf0b71d032fda01c19c17f414e5c60475b28',
'reference' => 'd72c4eac4e1624bb6b3dfbe90b06be607985b300',
'type' => 'project',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
......@@ -155,9 +155,9 @@
'dev_requirement' => false,
),
'cweagans/composer-patches' => array(
'pretty_version' => '1.7.0',
'version' => '1.7.0.0',
'reference' => 'ae02121445ad75f4eaff800cc532b5e6233e2ddf',
'pretty_version' => '1.7.3',
'version' => '1.7.3.0',
'reference' => 'e190d4466fe2b103a55467dfa83fc2fecfcaf2db',
'type' => 'composer-plugin',
'install_path' => __DIR__ . '/../cweagans/composer-patches',
'aliases' => array(),
......@@ -1615,7 +1615,7 @@
'osu-asc-webservices/d8-upstream' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => 'a904cf0b71d032fda01c19c17f414e5c60475b28',
'reference' => 'd72c4eac4e1624bb6b3dfbe90b06be607985b300',
'type' => 'project',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
......
......@@ -166,6 +166,33 @@ To enforce throwing an error and stopping package installation/update immediatel
By default, failed patches are skipped.
## Patches reporting
When a patch is applied, the plugin writes a report-file `PATCHES.txt` to a patching directory (e.g. `./patch-me/PATCHES.txt`),
which contains a list of applied patches.
If you want to avoid this behavior, add a specific key to the `extra` section:
```json
"extra": {
"composer-patches-skip-reporting": true
}
```
Or provide an environment variable `COMPOSER_PATCHES_SKIP_REPORTING` with a config.
## Patching composer.json in dependencies
This doesn't work like you'd want. By the time you're running `composer install`,
the metadata from your dependencies' composer.json has already been aggregated by
packagist (or whatever metadata repo you're using). Unfortunately, this means that
you cannot e.g. patch a dependency to be compatible with an earlier version of PHP
or change the framework version that a plugin depends on.
@anotherjames over at @computerminds wrote an article about how to work around
that particular problem for a Drupal 8 -> Drupal 9 upgrade:
[Apply Drupal 9 compatibility patches with Composer](https://www.computerminds.co.uk/articles/apply-drupal-9-compatibility-patches-composer) ([archive](https://web.archive.org/web/20210124171010/https://www.computerminds.co.uk/articles/apply-drupal-9-compatibility-patches-composer))
## Difference between this and netresearch/composer-patches-plugin
- This plugin is much more simple to use and maintain
......
......@@ -48,6 +48,11 @@ class Patches implements PluginInterface, EventSubscriberInterface {
*/
protected $patches;
/**
* @var array $installedPatches
*/
protected $installedPatches;
/**
* Apply plugin modifications to composer
*
......@@ -124,6 +129,7 @@ public function checkPatches(Event $event) {
}
// Remove packages for which the patch set has changed.
$promises = array();
foreach ($packages as $package) {
if (!($package instanceof AliasPackage)) {
$package_name = $package->getName();
......@@ -135,10 +141,14 @@ public function checkPatches(Event $event) {
|| ($has_patches && $has_applied_patches && $tmp_patches[$package_name] !== $extra['patches_applied'])) {
$uninstallOperation = new UninstallOperation($package, 'Removing package so it can be re-installed and re-patched.');
$this->io->write('<info>Removing package ' . $package_name . ' so that it can be re-installed and re-patched.</info>');
$installationManager->uninstall($localRepository, $uninstallOperation);
$promises[] = $installationManager->uninstall($localRepository, $uninstallOperation);
}
}
}
$promises = array_filter($promises);
if ($promises) {
$this->composer->getLoop()->wait($promises);
}
}
// If the Locker isn't available, then we don't need to do this.
// It's the first time packages have been installed.
......@@ -278,6 +288,7 @@ public function postInstall(PackageEvent $event) {
// Check if we should exit in failure.
$extra = $this->composer->getPackage()->getExtra();
$exitOnFailure = getenv('COMPOSER_EXIT_ON_PATCH_FAILURE') || !empty($extra['composer-exit-on-patch-failure']);
$skipReporting = getenv('COMPOSER_PATCHES_SKIP_REPORTING') || !empty($extra['composer-patches-skip-reporting']);
// Get the package object for the current operation.
$operation = $event->getOperation();
......@@ -324,7 +335,10 @@ public function postInstall(PackageEvent $event) {
$localPackage->setExtra($extra);
$this->io->write('');
$this->writePatchReport($this->patches[$package_name], $install_path);
if (true !== $skipReporting) {
$this->writePatchReport($this->patches[$package_name], $install_path);
}
}
/**
......@@ -555,6 +569,19 @@ protected function applyPatchWithGit($install_path, $patch_levels, $filename) {
return $patched;
}
/**
* Indicates if a package has been patched.
*
* @param \Composer\Package\PackageInterface $package
* The package to check.
*
* @return bool
* TRUE if the package has been patched.
*/
public static function isPackagePatched(PackageInterface $package) {
return array_key_exists('patches_applied', $package->getExtra());
}
/**
* {@inheritDoc}
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment