Skip to content

Commit

Permalink
Merge pull request #15 from markwbrown/main
Browse files Browse the repository at this point in the history
Update to skip merge commits
  • Loading branch information
aschbacd committed Nov 3, 2023
2 parents 3107485 + d21c472 commit ea3cd6d
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ async function run() {

if (eventName === "pull_request") {
// Print pull request title
core.info(`Pull request title: ${pullRequest.title}`)
core.info(`Pull request title: ${pullRequest.title}`)

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

payload.commits.forEach(commit => {

commitPromises.push(octokit.rest.repos.getCommit({
owner: owner,
repo: repo,
Expand All @@ -129,9 +130,13 @@ async function run() {
commits.push(commit)
}
}

// Check all commits
commits.forEach(commit => {
if (commit.parents && commit.parents.length > 1) {
core.info(`Merge commit detected: ${commit.sha}`);
return;
}
// Split commit message
let matches = regexCommitMessageSplit.exec(commit.commit.message)
let commitMessageSubject = matches[1]
Expand Down Expand Up @@ -168,7 +173,7 @@ async function run() {

if (!regexCommitCommitterName.test(commit.commit.committer.name))
core.setFailed(`Commit committer name does not match regex (${commit.sha.substr(0, 7)})`)

// Check for valid signature
if (prohibitUnsignedCommits && !commit.commit.verification.verified)
core.setFailed(`Commit has no valid signature (${commit.sha.substr(0, 7)})`)
Expand All @@ -191,7 +196,7 @@ async function run() {
core.setFailed(`Blank lines are not allowed in commit message body; line ${(index+1).toString()} (${commit.sha.substr(0, 7)})`)
} else if (commitMessageBodyMinLength != -1 && line.length < commitMessageBodyMinLength) {
core.setFailed(`Commit message body line ${(index+1).toString()} is too short (${commit.sha.substr(0, 7)})`)
}
}

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

0 comments on commit ea3cd6d

Please sign in to comment.