File tree Expand file tree Collapse file tree 4 files changed +18
-4
lines changed Expand file tree Collapse file tree 4 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -65,13 +65,15 @@ export async function gitCommit(lang: Lang = 'en-us') {
6565}
6666
6767/** Git commit message verify */
68- export async function gitCommitVerify ( lang : Lang = 'en-us' ) {
68+ export async function gitCommitVerify ( lang : Lang = 'en-us' , ignores : RegExp [ ] = [ ] ) {
6969 const gitPath = await execCommand ( 'git' , [ 'rev-parse' , '--show-toplevel' ] ) ;
7070
7171 const gitMsgPath = path . join ( gitPath , '.git' , 'COMMIT_EDITMSG' ) ;
7272
7373 const commitMsg = readFileSync ( gitMsgPath , 'utf8' ) . trim ( ) ;
7474
75+ if ( ignores . some ( regExp => regExp . test ( commitMsg ) ) ) return ;
76+
7577 const REG_EXP = / (?< type > [ a - z ] + ) (?: \( (?< scope > .+ ) \) ) ? (?< breaking > ! ) ? : (?< description > .+ ) / i;
7678
7779 if ( ! REG_EXP . test ( commitMsg ) ) {
Original file line number Diff line number Diff line change @@ -13,7 +13,17 @@ const defaultOptions: CliOption = {
1313 '!node_modules/**'
1414 ] ,
1515 ncuCommandArgs : [ '--deep' , '-u' ] ,
16- changelogOptions : { }
16+ changelogOptions : { } ,
17+ gitCommitVerifyIgnores : [
18+ / ^ ( ( M e r g e p u l l r e q u e s t ) | ( M e r g e ( .* ?) i n t o ( .* ?) | ( M e r g e b r a n c h ( .* ?) ) ) (?: \r ? \n ) * $ ) / m,
19+ / ^ ( M e r g e t a g ( .* ?) ) (?: \r ? \n ) * $ / m,
20+ / ^ ( R | r ) e v e r t ( .* ) / ,
21+ / ^ ( a m e n d | f i x u p | s q u a s h ) ! / ,
22+ / ^ ( M e r g e d ( .* ?) ( i n | i n t o ) ( .* ) | M e r g e d P R ( .* ) : ( .* ) ) / ,
23+ / ^ M e r g e r e m o t e - t r a c k i n g b r a n c h ( \s * ) ( .* ) / ,
24+ / ^ A u t o m a t i c m e r g e ( .* ) / ,
25+ / ^ A u t o - m e r g e d ( .* ?) i n t o ( .* ) /
26+ ]
1727} ;
1828
1929export async function loadCliOptions ( overrides ?: Partial < CliOption > , cwd = process . cwd ( ) ) {
Original file line number Diff line number Diff line change @@ -75,8 +75,8 @@ export async function setupCli() {
7575 } ,
7676 'git-commit-verify' : {
7777 desc : 'verify git commit message, make sure it match Conventional Commits standard' ,
78- action : async ( ) => {
79- await gitCommitVerify ( ) ;
78+ action : async args => {
79+ await gitCommitVerify ( args ?. lang , cliOptions . gitCommitVerifyIgnores ) ;
8080 }
8181 } ,
8282 changelog : {
Original file line number Diff line number Diff line change @@ -26,4 +26,6 @@ export interface CliOption {
2626 * @link https://github.com/soybeanjs/changelog
2727 */
2828 changelogOptions : Partial < ChangelogOption > ;
29+ /** The ignore pattern list of git commit verify */
30+ gitCommitVerifyIgnores : RegExp [ ] ;
2931}
You can’t perform that action at this time.
0 commit comments