@@ -4,9 +4,9 @@ const argv = require('yargs').argv;
4
4
const commitlint = require ( '@commitlint/cli' ) ;
5
5
6
6
const IF_CI = ! ! argv . ifCi ;
7
+ const PR_ONLY = ! ! argv . prOnly ;
7
8
8
- // Allow to override used bins for testing purposes
9
- const GIT = process . env . JENKINS_COMMITLINT_GIT_BIN || 'git' ;
9
+ // Allow override of used bins for testing purposes
10
10
const COMMITLINT = process . env . JENKINS_COMMITLINT_BIN ;
11
11
12
12
const REQUIRED = [ 'GIT_COMMIT' ] ;
@@ -40,14 +40,16 @@ async function main() {
40
40
// We could lint since the last successful commit, but that would require a bunch of extra logic
41
41
// to detect changes to commitlint.config.js or related modules.
42
42
await lint ( [ '--from' , start , '--to' , COMMIT ] ) ;
43
- } else {
43
+ } else if ( ! PR_ONLY ) {
44
+ // The --pr-only flag can be useful to use semantic-commitlint on the release branch instead of
45
+ // just linting one commit.
44
46
const input = await rawCommit ( COMMIT ) ;
45
47
await lint ( [ ] , { input } ) ;
46
48
}
47
49
}
48
50
49
51
async function getBase ( { branch, tip = 'HEAD' } ) {
50
- const result = await execa ( GIT , [ 'merge-base' , branch , tip ] ) ;
52
+ const result = await execa ( 'git' , [ 'merge-base' , branch , tip ] ) ;
51
53
return result . stdout ;
52
54
}
53
55
@@ -59,7 +61,7 @@ async function lint(args, options) {
59
61
}
60
62
61
63
async function rawCommit ( hash ) {
62
- const result = await execa ( GIT , [ 'show' , '--pretty=format:%B' , hash ] ) ;
64
+ const result = await execa ( 'git' , [ 'show' , '-s ', '--pretty=format:%B' , hash ] ) ;
63
65
return result . stdout ;
64
66
}
65
67
0 commit comments