Fix Component Project Changelog Checking (#42794)

This commit is contained in:
Christopher Allford 2023-12-13 15:41:11 -08:00 committed by GitHub
parent a232c32c8e
commit d0d49b49f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 1093 additions and 17 deletions

View File

@ -17,6 +17,7 @@
}, },
"extra": { "extra": {
"changelogger": { "changelogger": {
"changes-dir": "../woocommerce/changelog",
"formatter": { "formatter": {
"filename": "../../tools/changelogger/class-package-formatter.php" "filename": "../../tools/changelogger/class-package-formatter.php"
}, },

1071
plugins/woocommerce-admin/composer.lock generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -15,13 +15,12 @@
"php": "7.4" "php": "7.4"
}, },
"allow-plugins": { "allow-plugins": {
"composer/installers": true,
"dealerdirect/phpcodesniffer-composer-installer": true,
"automattic/jetpack-autoloader": true "automattic/jetpack-autoloader": true
} }
}, },
"extra": { "extra": {
"changelogger": { "changelogger": {
"changes-dir": "../woocommerce/changelog",
"formatter": { "formatter": {
"filename": "../../tools/changelogger/class-package-formatter.php" "filename": "../../tools/changelogger/class-package-formatter.php"
}, },

View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "7ce541cc88ff7d19723d117c1ac3a59b", "content-hash": "40f1e35cfc32070fda05769f2f481d39",
"packages": [], "packages": [],
"packages-dev": [ "packages-dev": [
{ {

View File

@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: This is only a change to the way changelogs are generated.

View File

@ -121,16 +121,21 @@ foreach ( $composer_projects as $project_path ) {
continue; continue;
} }
$data = isset( $data['extra']['changelogger'] ) ? $data['extra']['changelogger'] : array(); $data = isset( $data['extra']['changelogger'] ) ? $data['extra']['changelogger'] : array();
$data += array(
'changelog' => $project_path . '/CHANGELOG.md', if ( ! isset( $data[ 'changelog' ] ) ) {
'changes-dir' => $project_path . '/changelog', $data['changelog'] = $project_path . '/CHANGELOG.md';
); }
if ( ! isset( $data[ 'changes-dir' ] ) ) {
$data['changes-dir'] = $project_path . '/changelog';
}
$changelogger_projects[ $project_path ] = $data; $changelogger_projects[ $project_path ] = $data;
} }
// Support centralizing the changelogs for multiple components and validating them together. // Support centralizing the changelogs for multiple components and validating them together.
$project_component_map = array( $project_component_map = array(
'plugins/woocommerce-admin' => 'plugins/woocommerce', 'plugins/woocommerce-admin' => 'plugins/woocommerce',
'plugins/woocommerce-blocks' => 'plugins/woocommerce',
); );
// Process the diff. // Process the diff.
@ -160,15 +165,10 @@ while ( ( $line = fgets( $pipes[1] ) ) ) {
} }
} }
// Also try to match to project components. // Support overriding the project when checking a component.
if ( false === $project_match ) { if ( isset( $project_component_map[ $project_match ] ) ) {
foreach ( $project_component_map as $path => $project ) { $project_match = $project_component_map[ $project_match ];
if ( substr( $line, 0, strlen( $path ) + 1 ) === $path . '/' ) { debug( 'Mapping %s to project %s.', $line, $project_match );
debug( 'Mapping %s to project %s.', $line, $project );
$project_match = $project;
break;
}
}
} }
if ( false === $project_match ) { if ( false === $project_match ) {