Skip to content

Commit 549c972

Browse files
committed
Improved changelog parse
1 parent a9663b6 commit 549c972

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Command/ReleaseCommand.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,9 @@ private function parseChangelog($pull)
241241
{
242242
$changelog = array();
243243
$body = preg_replace('/<!--(.*)-->/Uis', '', $pull['body']);
244-
preg_match('/## Changelog.*```markdown(.*)```.*/is', $body, $matches);
244+
preg_match('/## Changelog.*```\s*markdown\s*\\n(.*)\\n```.*/is', $body, $matches);
245245

246-
if (false !== strpos($body, '## Changelog') && count($matches) == 2) {
246+
if (count($matches) == 2) {
247247
$lines = explode(PHP_EOL, $matches[1]);
248248

249249
$section = '';
@@ -254,8 +254,8 @@ private function parseChangelog($pull)
254254
continue;
255255
}
256256

257-
if (false !== strpos($line, '### ')) {
258-
$section = str_replace('### ', '', $line);
257+
if (0 === strpos($line, '#')) {
258+
$section = end(explode(' ', $line));
259259
} elseif (!empty($section)) {
260260
$line = preg_replace('/^- /i', '', $line);
261261
$changelog[$section][] = '- [[#'.$pull['number'].']('.$pull['html_url'].')] '.

0 commit comments

Comments
 (0)