File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -109,9 +109,12 @@ export class GitModule {
109109 const lastName = this . faker . person . lastName ( ) ;
110110 const fullName = this . faker . person . fullName ( { firstName, lastName } ) ;
111111 const username = this . faker . internet . userName ( firstName , lastName ) ;
112- const user = this . faker . helpers . arrayElement ( [ fullName , username ] ) ;
112+ let user = this . faker . helpers . arrayElement ( [ fullName , username ] ) ;
113113 const email = this . faker . internet . email ( firstName , lastName ) ;
114114
115+ // Normalize user according to https://github.com/libgit2/libgit2/issues/5342
116+ user = user . replace ( / ^ [ \. , : ; " \\ ' ] | [ \< \> \n ] | [ \. , : ; " \\ ' ] $ / g, '' ) ;
117+
115118 lines . push (
116119 `Author: ${ user } <${ email } >` ,
117120 `Date: ${ this . commitDate ( { refDate } ) } ` ,
Original file line number Diff line number Diff line change @@ -54,12 +54,12 @@ describe('git', () => {
5454 expect ( parts [ 0 ] ) . toMatch ( / ^ c o m m i t [ a - f 0 - 9 ] + $ / ) ;
5555 if ( parts . length === 7 ) {
5656 expect ( parts [ 1 ] ) . toMatch ( / ^ M e r g e : [ a - f 0 - 9 ] + [ a - f 0 - 9 ] + $ / ) ;
57- expect ( parts [ 2 ] ) . toMatch ( / ^ A u t h o r : [ \w _ \. ] + \< [ \w \. ] + @ [ \w \. ] + \> $ / ) ;
57+ expect ( parts [ 2 ] ) . toMatch ( / ^ A u t h o r : [ ^ \< \> ] + \< [ \w \. ] + @ [ \w \. ] + \> $ / ) ;
5858 expect ( parts [ 3 ] ) . toMatch ( / ^ D a t e : .+ $ / ) ;
5959 expect ( parts [ 4 ] ) . toBe ( '' ) ;
6060 expect ( parts [ 5 ] ) . toMatch ( / ^ \s { 4 } .+ $ / ) ;
6161 } else {
62- expect ( parts [ 1 ] ) . toMatch ( / ^ A u t h o r : [ \w _ \. ] + \< [ \w \. ] + @ [ \w \. ] + \> $ / ) ;
62+ expect ( parts [ 1 ] ) . toMatch ( / ^ A u t h o r : [ ^ \< \> ] + \< [ \w \. ] + @ [ \w \. ] + \> $ / ) ;
6363 expect ( parts [ 2 ] ) . toMatch ( / ^ D a t e : .+ $ / ) ;
6464 expect ( parts [ 3 ] ) . toBe ( '' ) ;
6565 expect ( parts [ 4 ] ) . toMatch ( / ^ \s { 4 } .+ $ / ) ;
You can’t perform that action at this time.
0 commit comments