2023-09-22 04:35:24 -04:00
|
|
|
const { recordRuleExitStatus } = require("./configParameters.js");
|
|
|
|
|
2023-02-21 02:56:09 -05:00
|
|
|
/**
|
|
|
|
* Check if MR Title contains prefix "WIP: ...".
|
|
|
|
*
|
|
|
|
* @dangerjs WARN
|
|
|
|
*/
|
|
|
|
module.exports = function () {
|
2023-09-22 04:35:24 -04:00
|
|
|
const ruleName = 'Merge request not in Draft or WIP state';
|
|
|
|
const mrTitle = danger.gitlab.mr.title;
|
2023-02-21 02:56:09 -05:00
|
|
|
const regexes = [
|
2023-09-22 04:35:24 -04:00
|
|
|
{ prefix: "WIP", regex: /^WIP:/i },
|
|
|
|
{ prefix: "W.I.P", regex: /^W\.I\.P/i },
|
|
|
|
{ prefix: "[WIP]", regex: /^\[WIP/i },
|
|
|
|
{ prefix: "[W.I.P]", regex: /^\[W\.I\.P/i },
|
|
|
|
{ prefix: "(WIP)", regex: /^\(WIP/i },
|
|
|
|
{ prefix: "(W.I.P)", regex: /^\(W\.I\.P/i },
|
2023-02-21 02:56:09 -05:00
|
|
|
];
|
|
|
|
|
2023-09-22 04:35:24 -04:00
|
|
|
for (const item of regexes) {
|
|
|
|
if (item.regex.test(mrTitle)) {
|
|
|
|
recordRuleExitStatus(ruleName, "Failed");
|
|
|
|
return warn(
|
|
|
|
`Please remove the \`${item.prefix}\` prefix from the MR name before merging this MR.`
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// At this point, the rule has passed
|
|
|
|
recordRuleExitStatus(ruleName, "Passed");
|
2023-02-21 02:56:09 -05:00
|
|
|
};
|