Skip to content

Commit

Permalink
check the commit message with regex to see if it is a "merge commit" …
Browse files Browse the repository at this point in the history
…/ simple branch update
  • Loading branch information
GrantBirki committed Sep 1, 2023
1 parent ae125b2 commit 064306d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
8 changes: 7 additions & 1 deletion __tests__/functions/identical-commit-check.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,20 @@ beforeEach(() => {
getBranch: jest.fn().mockReturnValue({
data: {
commit: {
sha: 'deadbeef'
sha: 'deadbeef',
commit: {
message: 'cool new feature'
}
}
}
}),
listCommits: jest.fn().mockReturnValue({
data: [
{
sha: 'deadbeef',
commit: {
message: 'cool new feature'
},
parents: [
{
sha: 'beefdead'
Expand Down
6 changes: 5 additions & 1 deletion dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion src/functions/identical-commit-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,12 @@ export async function identicalCommitCheck(octokit, context, environment) {
}
)
var latestCommitSha
const mergeCommitRegex = /^Merge branch .+ into .+$/
for (const commit of defaultBranchCommitsData) {
if (commit.parents.length === 1) {
if (
commit.parents.length === 1 &&
!mergeCommitRegex.test(commit.commit.message)
) {
latestCommitSha = commit.sha
break
}
Expand Down

0 comments on commit 064306d

Please sign in to comment.