From 2c6a2dd43b5d0607eae9ed7daff0338c6041dbdd Mon Sep 17 00:00:00 2001
From: Rhys Arkins <rhys@arkins.net>
Date: Tue, 19 Dec 2017 19:45:34 +0100
Subject: [PATCH] feat: better semantic commit detection

Limit to looking at last 10 commit messages and only use semantic commits if angular type is found.
---
 lib/workers/repository/updates/semantic.js | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/lib/workers/repository/updates/semantic.js b/lib/workers/repository/updates/semantic.js
index bc00d9a934..286cd2073b 100644
--- a/lib/workers/repository/updates/semantic.js
+++ b/lib/workers/repository/updates/semantic.js
@@ -5,16 +5,18 @@ async function detectSemanticCommits(config) {
     return config.semanticCommits;
   }
   const commitMessages = await platform.getCommitMessages();
+  if (commitMessages) {
+    commitMessages.length = 10;
+  }
   logger.trace(`commitMessages=${JSON.stringify(commitMessages)}`);
   const type = conventionalCommitsDetector(commitMessages);
-  if (type === 'unknown') {
-    logger.debug('No semantic commit type found');
-    return false;
+  logger.debug({ type }, 'Semantic commits detection');
+  if (type === 'angular') {
+    logger.info('angular semantic commits detected');
+    return true;
   }
-  logger.debug(
-    `Found semantic commit type ${type} - enabling semantic commits`
-  );
-  return true;
+  logger.info('No semantic commits detected');
+  return false;
 }
 
 module.exports = {
-- 
GitLab