2017-11-05 04:45:49 +00:00
|
|
|
const conventionalCommitsDetector = require('conventional-commits-detector');
|
|
|
|
|
|
|
|
async function detectSemanticCommits(config) {
|
2018-02-22 07:58:44 +00:00
|
|
|
logger.debug('detectSemanticCommits()');
|
|
|
|
logger.trace({ config });
|
2017-11-05 04:45:49 +00:00
|
|
|
if (config.semanticCommits !== null) {
|
2018-02-22 07:58:44 +00:00
|
|
|
logger.debug(
|
|
|
|
{ semanticCommits: config.semanticCommits },
|
|
|
|
`semanticCommits already defined`
|
|
|
|
);
|
2017-11-15 12:39:44 +00:00
|
|
|
return config.semanticCommits;
|
2017-11-05 04:45:49 +00:00
|
|
|
}
|
2017-11-07 10:46:10 +00:00
|
|
|
const commitMessages = await platform.getCommitMessages();
|
2017-12-19 18:45:34 +00:00
|
|
|
if (commitMessages) {
|
|
|
|
commitMessages.length = 10;
|
|
|
|
}
|
2017-11-05 04:45:49 +00:00
|
|
|
logger.trace(`commitMessages=${JSON.stringify(commitMessages)}`);
|
|
|
|
const type = conventionalCommitsDetector(commitMessages);
|
2017-12-19 18:45:34 +00:00
|
|
|
logger.debug({ type }, 'Semantic commits detection');
|
|
|
|
if (type === 'angular') {
|
|
|
|
logger.info('angular semantic commits detected');
|
|
|
|
return true;
|
2017-11-05 04:45:49 +00:00
|
|
|
}
|
2017-12-19 18:45:34 +00:00
|
|
|
logger.info('No semantic commits detected');
|
|
|
|
return false;
|
2017-11-05 04:45:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
detectSemanticCommits,
|
|
|
|
};
|