esp-idf/.gitlab/dangerjs/mrCommitsTooManyCommits.js
Tomas Sebestik dc5d4b0ac0 ci(danger-gitlab): Add CI job tracelog checks output
For role/check 'mrSourceBranchName' changed the output severity to warn (was info)
2023-09-22 10:35:24 +02:00

23 lines
756 B
JavaScript

const { recordRuleExitStatus } = require("./configParameters.js");
/**
* Check if MR has not an excessive numbers of commits (if squashed)
*
* @dangerjs INFO
*/
module.exports = function () {
const ruleName = 'Number of commits in merge request';
const tooManyCommitThreshold = 2; // above this number of commits, squash commits is suggested
const mrCommits = danger.gitlab.commits;
if (mrCommits.length > tooManyCommitThreshold) {
recordRuleExitStatus(ruleName, "Passed (with suggestions)");
return message(
`You might consider squashing your ${mrCommits.length} commits (simplifying branch history).`
);
}
// At this point, the rule has passed
recordRuleExitStatus(ruleName, 'Passed');
};