Skip to content

Real composer patches format #48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
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
30 changes: 24 additions & 6 deletions hooks/RoboFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,30 @@ public function updateDependencies()
*/
protected function getPatches($module)
{
$path = 'modules/' . $module . '/patches.json';
if (file_exists($path)) {
return json_decode(file_get_contents($path));
} else {
return new stdClass();
}
// Load composer configuration for the given module.
$config = json_decode(file_get_contents('modules/' . $module . '/composer.json'));

// If the module defines patches in composer.json, simply use them.
if (!empty($config->extra->{"patches"})) {
return $config->extra->{"patches"};
}

// Use the old patch file standard in drupal_tests, which was independent
// from any module composer.json patch specifications.
$patches_file = 'patches.json';
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 for this, we can remove it when Drupal 8.7 or 8.8 is out.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please take care. It follows only the default file name convention, not the old format. If the old/wrong composer patches format should be supported, we would need a different processing here.


// If the module defines an external composer patches file, use it.
if (!empty($config->extra->{"patches-file"})) {
$patches_file = $config->extra->{"patches-file"};
}

$path = 'modules/' . $module . '/' . $patches_file;
if (file_exists($path)) {
$patch_file_contents = json_decode(file_get_contents($path));
return $patch_file_contents->{"patches"};
}

return new stdClass();
}

/**
Expand Down
6 changes: 4 additions & 2 deletions templates/module/patches.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"drupal/coder": {
"CodeSniffer testing all file extensions instead of the configured ones": "https://www.drupal.org/files/issues/2867601.11-disable-txt-sniffs.patch"
"patches": {
"drupal/coder": {
"CodeSniffer testing all file extensions instead of the configured ones": "https://www.drupal.org/files/issues/2867601.11-disable-txt-sniffs.patch"
}
}
}