Skip to content

Commit d21c472

Browse files
committed
Skip merge commits
1 parent 3107485 commit d21c472

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

index.js

+9-4
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ async function run() {
5252

5353
if (eventName === "pull_request") {
5454
// Print pull request title
55-
core.info(`Pull request title: ${pullRequest.title}`)
55+
core.info(`Pull request title: ${pullRequest.title}`)
5656

5757
// Check pull request title
5858
if (!regexPullRequestTitle.test(pullRequest.title))
@@ -117,6 +117,7 @@ async function run() {
117117
let commitPromises = []
118118

119119
payload.commits.forEach(commit => {
120+
120121
commitPromises.push(octokit.rest.repos.getCommit({
121122
owner: owner,
122123
repo: repo,
@@ -129,9 +130,13 @@ async function run() {
129130
commits.push(commit)
130131
}
131132
}
132-
133+
133134
// Check all commits
134135
commits.forEach(commit => {
136+
if (commit.parents && commit.parents.length > 1) {
137+
core.info(`Merge commit detected: ${commit.sha}`);
138+
return;
139+
}
135140
// Split commit message
136141
let matches = regexCommitMessageSplit.exec(commit.commit.message)
137142
let commitMessageSubject = matches[1]
@@ -168,7 +173,7 @@ async function run() {
168173

169174
if (!regexCommitCommitterName.test(commit.commit.committer.name))
170175
core.setFailed(`Commit committer name does not match regex (${commit.sha.substr(0, 7)})`)
171-
176+
172177
// Check for valid signature
173178
if (prohibitUnsignedCommits && !commit.commit.verification.verified)
174179
core.setFailed(`Commit has no valid signature (${commit.sha.substr(0, 7)})`)
@@ -191,7 +196,7 @@ async function run() {
191196
core.setFailed(`Blank lines are not allowed in commit message body; line ${(index+1).toString()} (${commit.sha.substr(0, 7)})`)
192197
} else if (commitMessageBodyMinLength != -1 && line.length < commitMessageBodyMinLength) {
193198
core.setFailed(`Commit message body line ${(index+1).toString()} is too short (${commit.sha.substr(0, 7)})`)
194-
}
199+
}
195200

196201
if (commitMessageBodyMaxLength != -1 && line.length > commitMessageBodyMaxLength)
197202
core.setFailed(`Commit message body line ${(index+1).toString()} is too long (${commit.sha.substr(0, 7)})`)

0 commit comments

Comments
 (0)