Skip to content

Commit 8dd0fbf

Browse files
committed
fix: errors not showing when PR has only one commit
1 parent 526db9a commit 8dd0fbf

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

.github/workflows/commitlint.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
steps:
1010
- uses: actions/checkout@v1
1111
- run: sed -i -E "s/([']docker:.+)/Dockerfile/" ./action.yml
12-
- run: echo -n "" > .dockerignore
12+
- run: echo -n '' > .dockerignore
1313
- uses: ./
1414
commitlint-with-yml-file:
1515
runs-on: ubuntu-latest

run.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ const configPath = resolve(
1818

1919
const { context: eventContext } = github
2020

21-
const gitEmptySha = '0000000000000000000000000000000000000000'
21+
const pushEventHasOnlyOneCommit = from => {
22+
const gitEmptySha = '0000000000000000000000000000000000000000'
23+
24+
return from === gitEmptySha
25+
}
2226

2327
const getRangeForPushEvent = () => {
2428
let from = eventContext.payload.before
@@ -32,7 +36,7 @@ const getRangeForPushEvent = () => {
3236
from = null
3337
}
3438

35-
if (from === gitEmptySha) {
39+
if (pushEventHasOnlyOneCommit(from)) {
3640
from = null
3741
}
3842

@@ -58,7 +62,7 @@ const getRangeForEvent = async () => {
5862

5963
function getHistoryCommits(from, to) {
6064
const options = {
61-
from,
65+
from: from && `${from}^1`,
6266
to,
6367
}
6468

0 commit comments

Comments
 (0)