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') {
65
65
}
66
66
67
67
/** Git commit message verify */
68
- export async function gitCommitVerify ( lang : Lang = 'en-us' ) {
68
+ export async function gitCommitVerify ( lang : Lang = 'en-us' , ignores : RegExp [ ] = [ ] ) {
69
69
const gitPath = await execCommand ( 'git' , [ 'rev-parse' , '--show-toplevel' ] ) ;
70
70
71
71
const gitMsgPath = path . join ( gitPath , '.git' , 'COMMIT_EDITMSG' ) ;
72
72
73
73
const commitMsg = readFileSync ( gitMsgPath , 'utf8' ) . trim ( ) ;
74
74
75
+ if ( ignores . some ( regExp => regExp . test ( commitMsg ) ) ) return ;
76
+
75
77
const REG_EXP = / (?< type > [ a - z ] + ) (?: \( (?< scope > .+ ) \) ) ? (?< breaking > ! ) ? : (?< description > .+ ) / i;
76
78
77
79
if ( ! REG_EXP . test ( commitMsg ) ) {
Original file line number Diff line number Diff line change @@ -13,7 +13,17 @@ const defaultOptions: CliOption = {
13
13
'!node_modules/**'
14
14
] ,
15
15
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
+ ]
17
27
} ;
18
28
19
29
export 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() {
75
75
} ,
76
76
'git-commit-verify' : {
77
77
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 ) ;
80
80
}
81
81
} ,
82
82
changelog : {
Original file line number Diff line number Diff line change @@ -26,4 +26,6 @@ export interface CliOption {
26
26
* @link https://github.com/soybeanjs/changelog
27
27
*/
28
28
changelogOptions : Partial < ChangelogOption > ;
29
+ /** The ignore pattern list of git commit verify */
30
+ gitCommitVerifyIgnores : RegExp [ ] ;
29
31
}
You can’t perform that action at this time.
0 commit comments