Skip to content

Commit

Permalink
Merge branch 'feature/danger_commit_email' into 'master'
Browse files Browse the repository at this point in the history
ci: danger: check author/committer email

Closes IDF-6860

See merge request espressif/esp-idf!22646
  • Loading branch information
igrr committed Mar 31, 2023
2 parents 7c8e855 + eb3b2b5 commit cac58c5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitlab/dangerjs/dangerfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ async function runChecks() {
// Checks for MR commits
require("./mrCommitsTooManyCommits.js")();
require("./mrCommitsCommitMessage.js")();
require("./mrCommitsEmail.js")();

// Checks for MR code
require("./mrSizeTooLarge.js")();
Expand Down
16 changes: 16 additions & 0 deletions .gitlab/dangerjs/mrCommitsEmail.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* Check if the author is accidentally making a commit using a personal email
*
* @dangerjs INFO
*/
module.exports = function () {
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) {
return message(
`Some of the commits were authored or committed by developers outside Espressif: ${filteredEmails.join(', ')}. Please check if this is expected.`
);
}
};

0 comments on commit cac58c5

Please sign in to comment.