From dd93c1c194d60667f14d911d1b1af8800fa0eecf Mon Sep 17 00:00:00 2001
From: Rhys Arkins <rhys@arkins.net>
Date: Tue, 20 Mar 2018 10:07:50 +0100
Subject: [PATCH] fix: search changelogs down to fourth heading deep

Closes #1687
---
 lib/workers/pr/release-notes.js | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/lib/workers/pr/release-notes.js b/lib/workers/pr/release-notes.js
index 1a53fb9d8b..e5f426a9fe 100644
--- a/lib/workers/pr/release-notes.js
+++ b/lib/workers/pr/release-notes.js
@@ -93,8 +93,23 @@ async function getReleaseNotesMd(repository, version) {
     logger.trace('Could not parse top level headings. Trying second level');
     changelogParsed = changelogMd.match(/^##([^#]+?)\n([^]+?)(?=^##[^#])/gm);
     if (!changelogParsed || changelogParsed.length === 1) {
-      logger.info({ repository }, 'No second level changelogs headings found');
-      return null;
+      logger.debug({ repository }, 'No second level changelogs headings found');
+      changelogParsed = changelogMd.match(
+        /^###([^#]+?)\n([^]+?)(?=^###[^#])/gm
+      );
+      if (!changelogParsed || changelogParsed.length === 1) {
+        logger.debug(
+          { repository },
+          'No second third changelogs headings found'
+        );
+        changelogParsed = changelogMd.match(
+          /^####([^#]+?)\n([^]+?)(?=^####[^#])/gm
+        );
+        if (!changelogParsed || changelogParsed.length === 1) {
+          logger.info({ repository }, 'No changelogs headings found');
+          return null;
+        }
+      }
     }
   }
   for (const section of changelogParsed) {
-- 
GitLab