File tree Expand file tree Collapse file tree 2 files changed +25
-4
lines changed Expand file tree Collapse file tree 2 files changed +25
-4
lines changed Original file line number Diff line number Diff line change @@ -31,10 +31,7 @@ const getPushEventCommits = () => {
3131 return mappedCommits
3232}
3333
34- const getEventCommits = async ( ) => {
35- if ( ! pullRequestEvents . includes ( GITHUB_EVENT_NAME ) )
36- return getPushEventCommits ( )
37-
34+ const getPullRequestEventCommits = async ( ) => {
3835 const octokit = getOctokit ( getInput ( 'token' ) )
3936 const { owner, repo, number } = eventContext . issue
4037 const { data : commits } = await octokit . rest . pulls . listCommits ( {
@@ -50,6 +47,16 @@ const getEventCommits = async () => {
5047 } ) )
5148}
5249
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+
5360function getOptsFromConfig ( config ) {
5461 return {
5562 parserOpts :
Original file line number Diff line number Diff line change @@ -281,6 +281,20 @@ describe('Commit Linter action', () => {
281281 )
282282 } )
283283
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+
284298 describe . each ( [ 'pull_request' , 'pull_request_target' ] ) (
285299 'when there are multiple commits failing in the %s event' ,
286300 ( eventName ) => {
You can’t perform that action at this time.
0 commit comments