@@ -68,7 +68,7 @@ protected function processPR($repoName, $pr)
68
68
{
69
69
$ title = $ this ->cleanTitle ($ pr ['title ' ]);
70
70
$ id = '# ' . $ pr ['number ' ];
71
- if ($ repoName !== ' server ' ) {
71
+ if ($ repoName !== self :: REPO_SERVER ) {
72
72
$ id = $ repoName . $ id ;
73
73
}
74
74
$ data = [
@@ -163,7 +163,7 @@ protected function getReposToIterate($head = 'master')
163
163
// Return repos names
164
164
$ orgRepositories = array_map (fn ($ repo ): string => $ repo ['name ' ], $ results );
165
165
} catch (\Exception $ e ) {
166
- throw new Exception ('Unable to fetch the github repositories list. ' );
166
+ throw new Exception ('Unable to fetch the github repositories list: ' . $ e -> getMessage () );
167
167
}
168
168
169
169
return [...$ reposToIterate , ...array_intersect ($ orgRepositories , $ shippedApps )];
@@ -514,40 +514,48 @@ protected function execute(InputInterface $input, OutputInterface $output)
514
514
$ output ->writeln ("" );
515
515
$ output ->writeln ("<h4>Changes</h4> " );
516
516
$ output ->writeln ("<ul> " );
517
- foreach ($ prTitles ['closed ' ] as $ id => $ data ) {
518
- $ repoName = $ data ['repoName ' ];
519
- $ number = $ data ['number ' ];
520
- $ title = $ data ['title ' ];
521
- $ output ->writeln ("\t<li><a href= \"https://github.com/ $ orgName/ $ repoName/pull/ $ number \"> $ title ( $ repoName# $ number)</a></li> " );
517
+ $ closedPRs = $ this ->groupPRsByRepo ($ prTitles ['closed ' ]);
518
+ foreach ($ closedPRs as $ repo => $ prs ) {
519
+ $ output ->writeln ("<li><strong><a href= \"https://github.com/ $ orgName/ $ repo \"> $ repo</a></strong><ul> " );
520
+ foreach ($ prs as $ id => $ data ) {
521
+ $ repoName = $ data ['repoName ' ];
522
+ $ number = $ data ['number ' ];
523
+ $ title = $ data ['title ' ];
524
+ $ output ->writeln ("\t<li><a href= \"https://github.com/ $ orgName/ $ repoName/pull/ $ number \"> $ title ( $ repoName# $ number)</a></li> " );
525
+ }
526
+ $ output ->writeln ("</ul></li> " );
522
527
}
523
528
$ output ->writeln ("</ul> " );
524
- $ count = count ($ prTitles ['pending ' ]);
525
- if ($ count > 0 ) {
526
- $ output ->writeln ("<error> $ count pending PRs not printed - maybe the release is not ready yet</error> " );
527
- }
528
529
break ;
529
530
case 'forum ' :
530
- foreach ($ prTitles ['closed ' ] as $ id => $ data ) {
531
- $ repoName = $ data ['repoName ' ];
532
- $ number = $ data ['number ' ];
533
- $ title = $ data ['title ' ];
534
- $ output ->writeln ("* [ $ title ( $ repoName# $ number)](https://github.com/ $ orgName/ $ repoName/pull/ $ number) " );
535
- }
536
- $ count = count ($ prTitles ['pending ' ]);
537
- if ($ count > 0 ) {
538
- $ output ->writeln ("<error> $ count pending PRs not printed - maybe the release is not ready yet</error> " );
531
+ // Making it a second heading as the first one is the title of the post
532
+ $ output ->writeln ("## Nextcloud " . $ milestoneToCheck );
533
+ $ closedPRs = $ this ->groupPRsByRepo ($ prTitles ['closed ' ]);
534
+ foreach ($ closedPRs as $ repo => $ prs ) {
535
+ $ output ->writeln ("\n### [ $ repo](https://github.com/ $ orgName/ $ repo) " );
536
+ foreach ($ prs as $ id => $ data ) {
537
+ $ repoName = $ data ['repoName ' ];
538
+ $ number = $ data ['number ' ];
539
+ $ title = $ this ->escapeMarkdown ($ data ['title ' ]);
540
+ $ output ->writeln ("* [ $ title ( $ repoName# $ number)](https://github.com/ $ orgName/ $ repoName/pull/ $ number) " );
541
+ }
539
542
}
540
543
break ;
541
544
case 'markdown ' :
542
545
default :
543
- foreach ($ prTitles ['closed ' ] as $ id => $ data ) {
544
- $ repoName = $ data ['repoName ' ];
545
- $ number = $ data ['number ' ];
546
- $ title = $ data ['title ' ];
547
- if ($ repoName === 'server ' ) {
548
- $ output ->writeln ("* # $ number " );
549
- } else {
550
- $ output ->writeln ("* $ orgName/ $ repoName# $ number " );
546
+ $ output ->writeln ("## Nextcloud " . $ milestoneToCheck );
547
+ $ closedPRs = $ this ->groupPRsByRepo ($ prTitles ['closed ' ]);
548
+ foreach ($ closedPRs as $ repo => $ prs ) {
549
+ $ output ->writeln ("\n### [ $ repo](https://github.com/ $ orgName/ $ repo) " );
550
+ foreach ($ prs as $ id => $ data ) {
551
+ $ repoName = $ data ['repoName ' ];
552
+ $ number = $ data ['number ' ];
553
+ $ title = $ data ['title ' ];
554
+ if ($ repoName === self ::REPO_SERVER ) {
555
+ $ output ->writeln ("* # $ number " );
556
+ } else {
557
+ $ output ->writeln ("* $ orgName/ $ repoName# $ number " );
558
+ }
551
559
}
552
560
}
553
561
@@ -592,7 +600,7 @@ function ($a, $b) {
592
600
$ output ->writeln ("* $ author " );
593
601
$ prevAuthor = $ author ;
594
602
}
595
- if ($ repoName === ' server ' ) {
603
+ if ($ repoName === self :: REPO_SERVER ) {
596
604
$ output ->writeln (" * [ ] # $ number " );
597
605
} else {
598
606
$ output ->writeln (" * [ ] $ orgName/ $ repoName# $ number " );
@@ -606,6 +614,32 @@ function ($a, $b) {
606
614
# TODO
607
615
#$client->removeCache();
608
616
}
617
+
618
+ function escapeMarkdown (string $ text ): string {
619
+ // Escape characters that break markdown
620
+ $ escapeChars = ['* ' , '_ ' , '~ ' , '` ' , '[ ' , '] ' , '( ' , ') ' , '# ' , '+ ' , '- ' , '! ' , '| ' ];
621
+ foreach ($ escapeChars as $ char ) {
622
+ $ text = str_replace ($ char , '\\' . $ char , $ text );
623
+ }
624
+ return $ text ;
625
+ }
626
+
627
+ function groupPRsByRepo ($ prs ) {
628
+ $ grouped = [];
629
+ foreach ($ prs as $ pr ) {
630
+ $ repo = $ pr ['repoName ' ];
631
+ $ grouped [$ repo ][] = $ pr ;
632
+ }
633
+ ksort ($ grouped );
634
+
635
+ // Put server on top
636
+ if (isset ($ grouped [self ::REPO_SERVER ])) {
637
+ $ serverPRs = $ grouped [self ::REPO_SERVER ];
638
+ unset($ grouped [self ::REPO_SERVER ]);
639
+ $ grouped = array_merge ([self ::REPO_SERVER => $ serverPRs ], $ grouped );
640
+ }
641
+ return $ grouped ;
642
+ }
609
643
}
610
644
611
645
$ application = new Application ();
0 commit comments