2023-09-22 04:35:24 -04:00
|
|
|
const { recordRuleExitStatus } = require("./configParameters.js");
|
|
|
|
|
2023-03-07 18:02:37 -05:00
|
|
|
/**
|
|
|
|
* Check if the author is accidentally making a commit using a personal email
|
|
|
|
*
|
|
|
|
* @dangerjs INFO
|
|
|
|
*/
|
|
|
|
module.exports = function () {
|
2023-09-22 04:35:24 -04:00
|
|
|
const ruleName = 'Commits from outside Espressif';
|
2023-03-07 18:02:37 -05:00
|
|
|
const mrCommitAuthorEmails = danger.gitlab.commits.map(commit => commit.author_email);
|
|
|
|
const mrCommitCommitterEmails = danger.gitlab.commits.map(commit => commit.committer_email);
|
|
|
|
const emailPattern = /.*@espressif\.com/;
|
|
|
|
const filteredEmails = [...mrCommitAuthorEmails, ...mrCommitCommitterEmails].filter((email) => !emailPattern.test(email));
|
|
|
|
if (filteredEmails.length) {
|
2023-09-22 04:35:24 -04:00
|
|
|
recordRuleExitStatus(ruleName, "Failed");
|
2023-03-07 18:02:37 -05:00
|
|
|
return message(
|
|
|
|
`Some of the commits were authored or committed by developers outside Espressif: ${filteredEmails.join(', ')}. Please check if this is expected.`
|
|
|
|
);
|
|
|
|
}
|
2023-09-22 04:35:24 -04:00
|
|
|
|
|
|
|
// At this point, the rule has passed
|
|
|
|
recordRuleExitStatus(ruleName, 'Passed');
|
2023-03-07 18:02:37 -05:00
|
|
|
};
|