From 17c766a3cb4c5ad50591e32d2eddcbd54661d08e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6?= Date: Wed, 10 May 2023 08:59:37 +0200 Subject: [PATCH] feat(changelog): group PR list by author in markdown MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ --- changelog/index.php | 59 ++++++++++++++++++++++++++++----------------- 1 file changed, 37 insertions(+), 22 deletions(-) diff --git a/changelog/index.php b/changelog/index.php index c09a0cc..4e21e00 100644 --- a/changelog/index.php +++ b/changelog/index.php @@ -463,30 +463,45 @@ protected function execute(InputInterface $input, OutputInterface $output) $output->writeln("* $orgName/$repoName#$number"); } } + + // Do we have pending PRs? if (count($prTitles['pending'])) { - $output->writeln("\n\nPending PRs:\n"); - } - foreach ($prTitles['pending'] as $id => $data) { - $repoName = $data['repoName']; - $number = $data['number']; - $title = $data['title']; - $author = array_key_exists('author', $data) ? '@' . $data['author'] : ''; - if ($author === '@backportbot-nextcloud') { - $author = ''; - } - if ($author === '@dependabot-preview') { - $author = ''; - } - if ($author === '@dependabot') { - $author = ''; - } - if ($author === '@dependabot[bot]') { - $author = ''; + $output->writeln("\n\n## Pending PRs:"); + + // Group PR by authors + $pendingPRs = $prTitles['pending']; + function cmp($a, $b) { + return strnatcasecmp($a['author'], $b['author']); } - if ($repoName === 'server') { - $output->writeln("* [ ] #$number $author"); - } else { - $output->writeln("* [ ] $orgName/$repoName#$number $author"); + usort($pendingPRs, "cmp"); + + $prevAuthor = ''; + foreach ($pendingPRs as $id => $data) { + $repoName = $data['repoName']; + $number = $data['number']; + $title = $data['title']; + $author = array_key_exists('author', $data) ? '@' . $data['author'] : ''; + if ($author === '@backportbot-nextcloud') { + $author = ''; + } + if ($author === '@dependabot-preview') { + $author = ''; + } + if ($author === '@dependabot') { + $author = ''; + } + if ($author === '@dependabot[bot]') { + $author = ''; + } + if ($prevAuthor !== $author) { + $output->writeln("* $author"); + $prevAuthor = $author; + } + if ($repoName === 'server') { + $output->writeln(" * [ ] #$number"); + } else { + $output->writeln(" * [ ] $orgName/$repoName#$number"); + } } } break;