File tree 2 files changed +25
-4
lines changed 2 files changed +25
-4
lines changed Original file line number Diff line number Diff line change @@ -31,10 +31,7 @@ const getPushEventCommits = () => {
31
31
return mappedCommits
32
32
}
33
33
34
- const getEventCommits = async ( ) => {
35
- if ( ! pullRequestEvents . includes ( GITHUB_EVENT_NAME ) )
36
- return getPushEventCommits ( )
37
-
34
+ const getPullRequestEventCommits = async ( ) => {
38
35
const octokit = getOctokit ( getInput ( 'token' ) )
39
36
const { owner, repo, number } = eventContext . issue
40
37
const { data : commits } = await octokit . rest . pulls . listCommits ( {
@@ -50,6 +47,16 @@ const getEventCommits = async () => {
50
47
} ) )
51
48
}
52
49
50
+ const getEventCommits = async ( ) => {
51
+ if ( pullRequestEvents . includes ( GITHUB_EVENT_NAME ) ) {
52
+ return getPullRequestEventCommits ( )
53
+ }
54
+ if ( eventContext . payload . commits ) {
55
+ return getPushEventCommits ( )
56
+ }
57
+ return [ ]
58
+ }
59
+
53
60
function getOptsFromConfig ( config ) {
54
61
return {
55
62
parserOpts :
Original file line number Diff line number Diff line change @@ -281,6 +281,20 @@ describe('Commit Linter action', () => {
281
281
)
282
282
} )
283
283
284
+ it ( 'should pass when commits are not available' , async ( ) => {
285
+ td . when ( core . getInput ( 'configFile' ) ) . thenReturn ( './commitlint.config.js' )
286
+ cwd = await git . bootstrap ( 'fixtures/conventional' )
287
+ await createPushEventPayload ( cwd , { } )
288
+ updatePushEnvVars ( cwd )
289
+ td . replace ( process , 'cwd' , ( ) => cwd )
290
+ td . replace ( console , 'log' )
291
+
292
+ await runAction ( )
293
+
294
+ td . verify ( core . setFailed ( ) , { times : 0 , ignoreExtraArgs : true } )
295
+ td . verify ( console . log ( 'Lint free! 🎉' ) )
296
+ } )
297
+
284
298
describe . each ( [ 'pull_request' , 'pull_request_target' ] ) (
285
299
'when there are multiple commits failing in the %s event' ,
286
300
( eventName ) => {
You can’t perform that action at this time.
0 commit comments