Skip to content

Commit 85b201f

Browse files
committed
fix(travis-cli): lint ranges only for pr builds
1 parent 68ddfdd commit 85b201f

File tree

1 file changed

+8
-5
lines changed
  • @commitlint/travis-cli/src

1 file changed

+8
-5
lines changed

@commitlint/travis-cli/src/cli.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const COMMITLINT = process.env.TRAVIS_COMMITLINT_BIN;
99
const REQUIRED = [
1010
'TRAVIS_COMMIT',
1111
'TRAVIS_COMMIT_RANGE',
12+
'TRAVIS_EVENT_TYPE',
1213
'TRAVIS_REPO_SLUG',
1314
'TRAVIS_PULL_REQUEST_SLUG'
1415
];
@@ -17,6 +18,7 @@ const COMMIT = process.env.TRAVIS_COMMIT;
1718
const REPO_SLUG = process.env.TRAVIS_REPO_SLUG;
1819
const PR_SLUG = process.env.TRAVIS_PULL_REQUEST_SLUG || REPO_SLUG;
1920
const RANGE = process.env.TRAVIS_COMMIT_RANGE;
21+
const IS_PR = process.env.TRAVIS_EVENT_TYPE === 'pull_request';
2022

2123
main().catch(err => {
2224
console.log(err);
@@ -32,20 +34,21 @@ async function main() {
3234
// Make base and source available as dedicated remotes
3335
await Promise.all([
3436
() => fetch({name: 'base', url: `https://github.com/${REPO_SLUG}.git`}),
35-
() => fetch({name: 'source', url: `https://github.com/${PR_SLUG}.git`})
37+
IS_PR
38+
? () => fetch({name: 'source', url: `https://github.com/${PR_SLUG}.git`})
39+
: async () => {}
3640
]);
3741

3842
// Restore stashed changes if any
3943
await pop();
4044

4145
// Lint all commits in TRAVIS_COMMIT_RANGE if available
42-
if (RANGE) {
46+
if (IS_PR && RANGE) {
4347
const [start, end] = RANGE.split('.').filter(Boolean);
4448
await lint(['--from', start, '--to', end]);
49+
} else {
50+
await lint(['--from', COMMIT]);
4551
}
46-
47-
// Always lint the triggering commit indicated by TRAVIS_COMMIT
48-
await lint(['--from', COMMIT]);
4952
}
5053

5154
async function git(args, options) {

0 commit comments

Comments
 (0)