Skip to content

Commit 2518b2b

Browse files
committed
Be forgiving of missing author name and missing news list
1 parent 803cd34 commit 2518b2b

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/NewsFormatter.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public function __construct(array $releases) {
1111

1212
public function getNewsListForRelease(string $version): array {
1313
if (!isset($this->releases[$version])) {
14-
throw new \InvalidArgumentException('Given release not found in the releases set');
14+
return [];
1515
}
1616

1717
if (!isset($this->releases[$version]['version'], $this->releases[$version]['changes'])) {
@@ -38,6 +38,10 @@ public function getNewsListForRelease(string $version): array {
3838
public function getNewsListForReleaseMarkup(string $version): string {
3939
$release = $this->getNewsListForRelease($version);
4040

41+
if (empty($release)) {
42+
return '';
43+
}
44+
4145
$output = '';
4246

4347
foreach ($release['changes'] as $ext => $changes) {
@@ -54,10 +58,7 @@ public function getNewsListForReleaseMarkup(string $version): string {
5458
}
5559

5660
private function removeAuthorInBraces(string $change): string {
57-
$change = preg_replace('/^(.*) \([\w ,-]+\)$/', '$1', $change, 1, $count);
58-
if ($count !== 1) {
59-
throw new \RuntimeException('Failed to remove author braces in: '. $change);
60-
}
61+
$change = preg_replace('/(^(.*))( \([\w\p{L} ,-]+\).?$)/u', '$1', $change, 1, $count);
6162

6263
return $change;
6364
}

0 commit comments

Comments
 (0)