@@ -44,10 +44,10 @@ module.exports.commitAndTitleValidator = async (app, context) => {
44
44
* check Messages Format
45
45
* @param {String } pullRequestTitle
46
46
* @param {Array } commits
47
- * @param {Object } prTitle
48
- * @param {Object } commitMsg
47
+ * @param {Object } prTitleRegex
48
+ * @param {Object } commitMsgRegex
49
49
*/
50
- function checkMessagesFormat ( pullRequestTitle , commits , prTitle , commitMsg ) {
50
+ function checkMessagesFormat ( pullRequestTitle , commits , prTitleRegex , commitMsgRegex ) {
51
51
try {
52
52
let result = { } ;
53
53
let commitIds = [ ] ;
@@ -60,12 +60,13 @@ function checkMessagesFormat(pullRequestTitle, commits, prTitle, commitMsg) {
60
60
let commitMsgStatus = true ;
61
61
let commitMsgStatusMsg = messages . valid_commit_message ;
62
62
let outputTitle = outputTitleFail ;
63
+ let output = { } ;
63
64
/**
64
65
* pull Request Title check : starts
65
66
*/
66
67
// pull request title format
67
68
let mergePattern = / ^ ( M e r g e p u l l r e q u e s t ) / ;
68
- if ( checkRegex ( pullRequestTitle , prTitle ) ) {
69
+ if ( checkRegex ( pullRequestTitle , prTitleRegex ) ) {
69
70
pullReqTitleStatus = true ;
70
71
pullReqTitleStatusMsg = messages . valid_pull_request_message ;
71
72
} else {
@@ -86,7 +87,7 @@ function checkMessagesFormat(pullRequestTitle, commits, prTitle, commitMsg) {
86
87
const element = commits [ index ] ;
87
88
const commitMessage = element . commit . message ;
88
89
commitIds . push ( commits [ index ] . sha ) ;
89
- if ( ! checkRegex ( commitMessage , commitMsg ) && ! checkRegex ( commitMessage , mergePattern ) ) {
90
+ if ( ! checkRegex ( commitMessage , commitMsgRegex ) && ! checkRegex ( commitMessage , mergePattern ) ) {
90
91
invalidCommitsCount ++ ;
91
92
commitMsgStatus = false ;
92
93
commitMsgStatusMsg = messages . invalid_commit_message ;
@@ -114,11 +115,28 @@ function checkMessagesFormat(pullRequestTitle, commits, prTitle, commitMsg) {
114
115
/**
115
116
* set check run status
116
117
*/
117
- let status = checkRunStatusCompleted ;
118
- let output = {
118
+ output = {
119
119
title : outputTitle ,
120
- summary : `${ pullReqTitleStatusMsg } <br/>${ commitMsgStatusMsg } <br/>${ invalidCommits } <br/>${ invalidCommitsCount } ${ otherInvalidCommitMessages } `
120
+ summary : `${ pullReqTitleStatusMsg } <br/>${ commitMsgStatusMsg } <br/>${ invalidCommits } <br/>`
121
121
} ;
122
+ let status = checkRunStatusCompleted ;
123
+ if ( ( ! prTitleRegex || ! prTitleRegex . regexPattern ) && ( ! commitMsgRegex || ! commitMsgRegex . regexPattern ) ) {
124
+ // pull request and commit message configration regex not set
125
+ output . title = `${ messages . pr_and_commit_message_configuration_not_set } ` ;
126
+ output . summary = `${ messages . pr_and_commit_message_configuration_not_set } <br/>` ;
127
+ } else if ( ! commitMsgRegex || ! commitMsgRegex . regexPattern ) {
128
+ // commit message configration regex not set
129
+ output . title = `${ messages . commit_message_configuration_not_set } ` ;
130
+ output . summary = `${ pullReqTitleStatusMsg } <br/>${ messages . commit_message_configuration_not_set } <br/>` ;
131
+ } else if ( ! prTitleRegex || ! prTitleRegex . regexPattern ) {
132
+ // pull request configration regex not set
133
+ output . title = `${ messages . pr_configuration_not_set } ` ;
134
+ output . summary = `${ messages . pr_configuration_not_set } <br/>${ commitMsgStatusMsg } <br/>${ invalidCommits } <br/>` ;
135
+ }
136
+ // set invalid commit messages and count
137
+ if ( invalidCommitsCount && invalidCommitsCount >= defaultJson . INVALID_COMMIT_LIMIT ) {
138
+ output . summary += `${ invalidCommitsCount } ${ otherInvalidCommitMessages } ` ;
139
+ }
122
140
result = {
123
141
commitIds,
124
142
status,
0 commit comments