@@ -44,10 +44,10 @@ module.exports.commitAndTitleValidator = async (app, context) => {
4444 * check Messages Format
4545 * @param {String } pullRequestTitle
4646 * @param {Array } commits
47- * @param {Object } prTitle
48- * @param {Object } commitMsg
47+ * @param {Object } prTitleRegex
48+ * @param {Object } commitMsgRegex
4949 */
50- function checkMessagesFormat ( pullRequestTitle , commits , prTitle , commitMsg ) {
50+ function checkMessagesFormat ( pullRequestTitle , commits , prTitleRegex , commitMsgRegex ) {
5151 try {
5252 let result = { } ;
5353 let commitIds = [ ] ;
@@ -60,12 +60,13 @@ function checkMessagesFormat(pullRequestTitle, commits, prTitle, commitMsg) {
6060 let commitMsgStatus = true ;
6161 let commitMsgStatusMsg = messages . valid_commit_message ;
6262 let outputTitle = outputTitleFail ;
63+ let output = { } ;
6364 /**
6465 * pull Request Title check : starts
6566 */
6667 // pull request title format
6768 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 ) ) {
6970 pullReqTitleStatus = true ;
7071 pullReqTitleStatusMsg = messages . valid_pull_request_message ;
7172 } else {
@@ -86,7 +87,7 @@ function checkMessagesFormat(pullRequestTitle, commits, prTitle, commitMsg) {
8687 const element = commits [ index ] ;
8788 const commitMessage = element . commit . message ;
8889 commitIds . push ( commits [ index ] . sha ) ;
89- if ( ! checkRegex ( commitMessage , commitMsg ) && ! checkRegex ( commitMessage , mergePattern ) ) {
90+ if ( ! checkRegex ( commitMessage , commitMsgRegex ) && ! checkRegex ( commitMessage , mergePattern ) ) {
9091 invalidCommitsCount ++ ;
9192 commitMsgStatus = false ;
9293 commitMsgStatusMsg = messages . invalid_commit_message ;
@@ -114,11 +115,28 @@ function checkMessagesFormat(pullRequestTitle, commits, prTitle, commitMsg) {
114115 /**
115116 * set check run status
116117 */
117- let status = checkRunStatusCompleted ;
118- let output = {
118+ output = {
119119 title : outputTitle ,
120- summary : `${ pullReqTitleStatusMsg } <br/>${ commitMsgStatusMsg } <br/>${ invalidCommits } <br/>${ invalidCommitsCount } ${ otherInvalidCommitMessages } `
120+ summary : `${ pullReqTitleStatusMsg } <br/>${ commitMsgStatusMsg } <br/>${ invalidCommits } <br/>`
121121 } ;
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+ }
122140 result = {
123141 commitIds,
124142 status,
0 commit comments