File tree Expand file tree Collapse file tree 4 files changed +28
-7
lines changed Expand file tree Collapse file tree 4 files changed +28
-7
lines changed Original file line number Diff line number Diff line change @@ -3,21 +3,29 @@ module.exports = {
3
3
{
4
4
name : 'Changes' ,
5
5
regExp : / [ \u4e00 - \u9fa5 ] / ,
6
- }
6
+ } ,
7
7
] ,
8
8
parse ( commits ) {
9
- let output = '' ;
9
+ const feats = [ ]
10
+ const fixs = [ ]
11
+ const others = [ ]
10
12
11
13
commits . forEach ( ( log ) => {
12
14
log . results . forEach ( ( result ) => {
13
- output += `${ result . filter . name } :\n` ;
14
-
15
15
result . commits . forEach ( ( commit ) => {
16
- output += `- ${ commit . s } ${ commit . an } \n` ;
16
+ const logText = `- ${ commit . s } ${ commit . an } `
17
+
18
+ if ( / f e a t / . test ( commit . s ) ) {
19
+ feats . push ( logText )
20
+ } else if ( / f i x / . test ( commit . s ) ) {
21
+ fixs . push ( logText )
22
+ } else {
23
+ others . push ( logText )
24
+ }
17
25
} ) ;
18
26
} ) ;
19
27
} ) ;
20
28
21
- return output ;
29
+ return ` ${ feats . join ( '\n' ) } \n\n ${ fixs . join ( '\n' ) } \n\n ${ others . join ( '\n' ) } ` ;
22
30
}
23
31
} ;
Original file line number Diff line number Diff line change 1
1
Picklog
2
2
====
3
- [ ![ Build Status] ( https://travis-ci.org/BearJ/picklog.svg?branch=master )] ( https://travis-ci.org/BearJ/picklog )
4
3
[ ![ npm version] ( https://img.shields.io/npm/v/picklog.svg )] ( https://www.npmjs.org/package/picklog )
5
4
6
5
根据你设置的filter,提取出你需要的log,从而生成changelog。可以生成` JSON ` 或` markdown ` 。
Original file line number Diff line number Diff line change
1
+ const fs = require ( 'fs' ) ;
2
+ const path = require ( 'path' ) ;
3
+ const picklog = require ( '../index' ) ;
4
+
5
+ const lastCommit = fs . readFileSync ( path . resolve ( '.lastcommit' ) , 'utf8' ) . trim ( ) ;
6
+
7
+ picklog ( {
8
+ gitLogArgs : `...${ lastCommit } ` ,
9
+ config : '.picklogrc.devops.js' ,
10
+ } ) . then ( ( text ) => {
11
+ console . log ( text ) ;
12
+ } ) ;
Original file line number Diff line number Diff line change @@ -46,6 +46,8 @@ module.exports = {
46
46
arg : `--pretty=${ Object . values ( format ) . join ( SPLIT ) } ${ END } ` ,
47
47
48
48
parse ( result ) {
49
+ if ( ! result ) return [ ] ;
50
+
49
51
const keys = Object . keys ( format ) ;
50
52
const commitsStr = result . trim ( ) ;
51
53
if ( ! commitsStr . length ) return [ ] ;
You can’t perform that action at this time.
0 commit comments