Skip to content

Commit 2f931d9

Browse files
committed
[TASK] Ignore merge commits for push event
1 parent 8c35571 commit 2f931d9

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

__tests__/input-helper.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,7 @@ describe('input-helper tests', () => {
553553
expect(checkerArguments.pattern).toBe('some-pattern')
554554
expect(checkerArguments.error).toBe('some-error')
555555
expect(checkerArguments.messages).toBeTruthy()
556+
expect(checkerArguments.messages.length).toBe(1)
556557
expect(checkerArguments.messages[0]).toBe('some-message')
557558
})
558559

@@ -566,6 +567,12 @@ describe('input-helper tests', () => {
566567
},
567568
{
568569
message: 'other-message'
570+
},
571+
{
572+
message: 'ignored-message',
573+
parents: {
574+
totalCount: 2
575+
}
569576
}
570577
]
571578
}
@@ -577,6 +584,7 @@ describe('input-helper tests', () => {
577584
expect(checkerArguments.pattern).toBe('some-pattern')
578585
expect(checkerArguments.error).toBe('some-error')
579586
expect(checkerArguments.messages).toBeTruthy()
587+
expect(checkerArguments.messages.length).toBe(2)
580588
expect(checkerArguments.messages[0]).toBe('some-message')
581589
expect(checkerArguments.messages[1]).toBe('other-message')
582590
})

dist/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ exports.getInputs = getInputs;
236236
* @returns string[]
237237
*/
238238
function getMessages(pullRequestOptions) {
239-
var _a;
239+
var _a, _b, _c;
240240
return __awaiter(this, void 0, void 0, function* () {
241241
core.debug('Get messages...');
242242
core.debug(` - pullRequestOptions: ${JSON.stringify(pullRequestOptions, null, 2)}`);
@@ -311,7 +311,9 @@ function getMessages(pullRequestOptions) {
311311
break;
312312
}
313313
for (const i in github.context.payload.commits) {
314-
if (github.context.payload.commits[i].message) {
314+
if (github.context.payload.commits[i].message &&
315+
// ignore merge commits
316+
((_c = (_b = github.context.payload.commits[i].parents) === null || _b === void 0 ? void 0 : _b.totalCount) !== null && _c !== void 0 ? _c : 1) === 1) {
315317
messages.push(github.context.payload.commits[i].message);
316318
}
317319
}

src/input-helper.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,11 @@ async function getMessages(
201201
}
202202

203203
for (const i in github.context.payload.commits) {
204-
if (github.context.payload.commits[i].message) {
204+
if (
205+
github.context.payload.commits[i].message &&
206+
// ignore merge commits
207+
(github.context.payload.commits[i].parents?.totalCount ?? 1) === 1
208+
) {
205209
messages.push(github.context.payload.commits[i].message)
206210
}
207211
}

0 commit comments

Comments
 (0)