From 7d0b4f32d51339d6e4f8fd9f7ea77573057fc5e0 Mon Sep 17 00:00:00 2001 From: Liam Morland Date: Wed, 12 Jan 2022 11:21:20 -0500 Subject: [PATCH 1/8] ISTWCMS-5291: Base release notes on wcms/drupal-recommended-project --- uw_wcms_tools.releasenotes.inc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/uw_wcms_tools.releasenotes.inc b/uw_wcms_tools.releasenotes.inc index b24df0c..7a4a22c 100644 --- a/uw_wcms_tools.releasenotes.inc +++ b/uw_wcms_tools.releasenotes.inc @@ -22,12 +22,12 @@ 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 wcms/drupal-recommended-project 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. $projects = []; foreach (array_keys($tags) as $stage) { - $composer = uw_wcms_tools_gitlab_get_file('wcms/uw_base_profile', 'composer.json', $tags[$stage]); + $composer = uw_wcms_tools_gitlab_get_file('wcms/drupal-recommended-project', 'composer.json', $tags[$stage]); if ($composer['http_status'] !== 200) { throw new Exception('Unable to load composer.json.'); } -- GitLab From 837bf27c8ed6a53d6e1aab6f30ec34eae0439076 Mon Sep 17 00:00:00 2001 From: Liam Morland Date: Wed, 12 Jan 2022 13:57:43 -0500 Subject: [PATCH 2/8] ISTWCMS-5291: Add root project so that changes to it are included in the commit and ticket output --- uw_wcms_tools.releasenotes.inc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/uw_wcms_tools.releasenotes.inc b/uw_wcms_tools.releasenotes.inc index 7a4a22c..81267cd 100644 --- a/uw_wcms_tools.releasenotes.inc +++ b/uw_wcms_tools.releasenotes.inc @@ -66,6 +66,10 @@ 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; + uw_wcms_tools_gitlab_get_project_commits($projects); // Generate a list of updated WCMS projects and the commits each has had. -- GitLab From a28d8ef3ddafcbf4ee25d6c2b2ee454fc8fcedc4 Mon Sep 17 00:00:00 2001 From: Liam Morland Date: Wed, 12 Jan 2022 13:58:22 -0500 Subject: [PATCH 3/8] ISTWCMS-5291: Sort and remove duplicates in commit message output --- uw_wcms_tools.releasenotes.inc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/uw_wcms_tools.releasenotes.inc b/uw_wcms_tools.releasenotes.inc index 81267cd..655453d 100644 --- a/uw_wcms_tools.releasenotes.inc +++ b/uw_wcms_tools.releasenotes.inc @@ -80,10 +80,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"; -- GitLab From e059709f547e0faec06bd553467c83439c39c003 Mon Sep 17 00:00:00 2001 From: Liam Morland Date: Wed, 12 Jan 2022 13:51:01 -0500 Subject: [PATCH 4/8] ISTWCMS-5291: Refactor 'foreach' statement --- uw_wcms_tools.releasenotes.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/uw_wcms_tools.releasenotes.inc b/uw_wcms_tools.releasenotes.inc index 655453d..6b2c887 100644 --- a/uw_wcms_tools.releasenotes.inc +++ b/uw_wcms_tools.releasenotes.inc @@ -26,8 +26,8 @@ function uw_wcms_tools_release_notes_generate(string $start, string $end): strin // revision. Make an array of required project names and the version of each // at the start and end revisions. $projects = []; - foreach (array_keys($tags) as $stage) { - $composer = uw_wcms_tools_gitlab_get_file('wcms/drupal-recommended-project', 'composer.json', $tags[$stage]); + foreach ($tags as $stage => $tag) { + $composer = uw_wcms_tools_gitlab_get_file('wcms/drupal-recommended-project', 'composer.json', $tag); if ($composer['http_status'] !== 200) { throw new Exception('Unable to load composer.json.'); } -- GitLab From 01ff09fda2491bf60894041332a9b5327ef345a2 Mon Sep 17 00:00:00 2001 From: Liam Morland Date: Wed, 12 Jan 2022 13:52:49 -0500 Subject: [PATCH 5/8] ISTWCMS-5291: Protect against empty 'require' section --- uw_wcms_tools.releasenotes.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uw_wcms_tools.releasenotes.inc b/uw_wcms_tools.releasenotes.inc index 6b2c887..5ee9f2d 100644 --- a/uw_wcms_tools.releasenotes.inc +++ b/uw_wcms_tools.releasenotes.inc @@ -33,7 +33,7 @@ function uw_wcms_tools_release_notes_generate(string $start, string $end): strin } $composer = json_decode($composer['body']->content); - foreach ($composer->require as $name => $version) { + foreach (($composer->require ?? []) as $name => $version) { $projects[$name][$stage] = $version; } } -- GitLab From d2edd0a981863e4db0a3e98bb6ce2ed1441df9ab Mon Sep 17 00:00:00 2001 From: Liam Morland Date: Wed, 12 Jan 2022 13:53:55 -0500 Subject: [PATCH 6/8] ISTWCMS-5291: Refactor: Use 'foreach' for projects to scan --- uw_wcms_tools.releasenotes.inc | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/uw_wcms_tools.releasenotes.inc b/uw_wcms_tools.releasenotes.inc index 5ee9f2d..7ac6c3f 100644 --- a/uw_wcms_tools.releasenotes.inc +++ b/uw_wcms_tools.releasenotes.inc @@ -22,19 +22,26 @@ function uw_wcms_tools_release_notes_generate(string $start, string $end): strin 'end' => $end, ]; - // Load wcms/drupal-recommended-project composer.json from the start and end + // 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 ($tags as $stage => $tag) { - $composer = uw_wcms_tools_gitlab_get_file('wcms/drupal-recommended-project', 'composer.json', $tag); - 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', + ]; + 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; + } } } -- GitLab From b19fd093524575ad719e6628783c038d35f2a869 Mon Sep 17 00:00:00 2001 From: Liam Morland Date: Wed, 12 Jan 2022 13:56:06 -0500 Subject: [PATCH 7/8] ISTWCMS-5291: Add uw_base_profile to projects to have their composer.json files scanned --- uw_wcms_tools.releasenotes.inc | 1 + 1 file changed, 1 insertion(+) diff --git a/uw_wcms_tools.releasenotes.inc b/uw_wcms_tools.releasenotes.inc index 7ac6c3f..9d93baa 100644 --- a/uw_wcms_tools.releasenotes.inc +++ b/uw_wcms_tools.releasenotes.inc @@ -30,6 +30,7 @@ function uw_wcms_tools_release_notes_generate(string $start, string $end): strin $projects = []; $projects_to_scan = [ 'wcms/drupal-recommended-project', + 'wcms/uw_base_profile', ]; foreach ($projects_to_scan as $project) { foreach ($tags as $stage => $tag) { -- GitLab From 79e1eed0267092ad25d5ecaac2e55415b0076e23 Mon Sep 17 00:00:00 2001 From: Liam Morland Date: Wed, 12 Jan 2022 14:07:56 -0500 Subject: [PATCH 8/8] ISTWCMS-5291: Sort projects --- uw_wcms_tools.releasenotes.inc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/uw_wcms_tools.releasenotes.inc b/uw_wcms_tools.releasenotes.inc index 9d93baa..b41f015 100644 --- a/uw_wcms_tools.releasenotes.inc +++ b/uw_wcms_tools.releasenotes.inc @@ -78,6 +78,8 @@ function uw_wcms_tools_release_notes_generate(string $start, string $end): strin // 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. -- GitLab