@@ -4,9 +4,9 @@ const argv = require('yargs').argv;
44const commitlint = require ( '@commitlint/cli' ) ;
55
66const IF_CI = ! ! argv . ifCi ;
7+ const PR_ONLY = ! ! argv . prOnly ;
78
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
1010const COMMITLINT = process . env . JENKINS_COMMITLINT_BIN ;
1111
1212const REQUIRED = [ 'GIT_COMMIT' ] ;
@@ -40,14 +40,16 @@ async function main() {
4040 // We could lint since the last successful commit, but that would require a bunch of extra logic
4141 // to detect changes to commitlint.config.js or related modules.
4242 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.
4446 const input = await rawCommit ( COMMIT ) ;
4547 await lint ( [ ] , { input } ) ;
4648 }
4749}
4850
4951async 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 ] ) ;
5153 return result . stdout ;
5254}
5355
@@ -59,7 +61,7 @@ async function lint(args, options) {
5961}
6062
6163async 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 ] ) ;
6365 return result . stdout ;
6466}
6567
0 commit comments