-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathccc.js
46 lines (45 loc) · 1.54 KB
/
ccc.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
export function validatePR({
title,
body,
prTitleRegexPattern,
prBodyRegexPattern,
}) {
const prTitleRegExp = new RegExp(prTitleRegexPattern);
const prTitleMatchResult = prTitleRegExp.test(title);
if (!prTitleMatchResult) {
return {
status: "failure",
message: `Pull request title
**************************************************************************************
${title}
**************************************************************************************
does not match ${prTitleRegexPattern}`,
};
}
const prBodyRegExp = new RegExp(prBodyRegexPattern);
if (!prBodyRegExp.test(body)) {
return {
status: "failure",
message: `Pull request body
**************************************************************************************
${body}
**************************************************************************************
does not match ${prBodyRegexPattern}`,
};
}
return {
status: "success",
message: `
Pull request title
**************************************************************************************
${title}
**************************************************************************************
matches ${prTitleRegexPattern}
Pull request body
**************************************************************************************
${body}
**************************************************************************************
matches ${prBodyRegexPattern}
`,
};
}