diff --git a/uw_wcms_tools.releasenotes.inc b/uw_wcms_tools.releasenotes.inc index b24df0c77257e1862e47b2bf723ab7d2a1d1afb5..b41f0152c7c0735b67f08323fb3765a1f24fad84 100644 --- a/uw_wcms_tools.releasenotes.inc +++ b/uw_wcms_tools.releasenotes.inc @@ -22,19 +22,27 @@ function uw_wcms_tools_release_notes_generate(string $start, string $end): strin 'end' => $end, ]; - // Load uw_base_profile composer.json from the start and end revision. Make an - // array of required project names and the version of each at the start and - // end revisions. + // Load composer.json from the projects to scan from the start and end + // revision. Make an array of required project names and the version of each + // at the start and end revisions. + // If a project required in more than one composer.json file, the last one in + // that stage is used. $projects = []; - foreach (array_keys($tags) as $stage) { - $composer = uw_wcms_tools_gitlab_get_file('wcms/uw_base_profile', 'composer.json', $tags[$stage]); - if ($composer['http_status'] !== 200) { - throw new Exception('Unable to load composer.json.'); - } - $composer = json_decode($composer['body']->content); + $projects_to_scan = [ + 'wcms/drupal-recommended-project', + 'wcms/uw_base_profile', + ]; + foreach ($projects_to_scan as $project) { + foreach ($tags as $stage => $tag) { + $composer = uw_wcms_tools_gitlab_get_file($project, 'composer.json', $tag); + if ($composer['http_status'] !== 200) { + throw new Exception('Unable to load composer.json.'); + } + $composer = json_decode($composer['body']->content); - foreach ($composer->require as $name => $version) { - $projects[$name][$stage] = $version; + foreach (($composer->require ?? []) as $name => $version) { + $projects[$name][$stage] = $version; + } } } @@ -66,6 +74,12 @@ function uw_wcms_tools_release_notes_generate(string $start, string $end): strin $release_notes .= "\n"; + // Add root project so that changes to it are included in the commit and + // ticket output. + $projects['wcms/drupal-recommended-project'] = $tags; + + ksort($projects); + uw_wcms_tools_gitlab_get_project_commits($projects); // Generate a list of updated WCMS projects and the commits each has had. @@ -76,10 +90,20 @@ function uw_wcms_tools_release_notes_generate(string $start, string $end): strin continue; } list(, $project) = explode('/', $path, 2); - $release_notes .= $project . "\n"; + + // Make array of commit messages for this project for this release. + $project_commits = []; foreach ($commits['commits'] as $commit) { - $release_notes .= "\t" . $commit->title . "\n"; + $project_commits[] = trim($commit->title); } + // Sort and remove duplicates. + sort($project_commits); + $project_commits = array_unique($project_commits); + + // Format list of commit messages. + $release_notes .= $project . "\n\t"; + $release_notes .= implode("\n\t", $project_commits); + $release_notes .= "\n"; } $release_notes .= "\n";