@@ -61,12 +61,13 @@ const setup = () => {
6161
6262const date = / \( [ 0 - 9 ] { 4 } - [ 0 - 9 ] { 2 } - [ 0 - 9 ] { 2 } \) / . source ;
6363const sha = / [ 0 - 9 a - f ] { 7 } / . source ;
64+ const shaLong = / [ 0 - 9 a - f ] { 40 } / . source ;
6465const level = ( from , to ) => `${ / p a t c h / . test ( semver . diff ( from , to ) ) ? '##' : '#' } ` ;
65- const header = ( from , to , suffix = '' ) =>
66- `${ level ( from , to ) } \\[${ to } \\]\\(/compare/${ from } ${ suffix } ...${ to } ${ suffix } \\) ${ date } ` ;
66+ const header = ( from , to , suffix = '' , url = '' ) =>
67+ `${ level ( from , to ) } \\[${ to } \\]\\(${ url } /compare/${ from } ${ suffix } ...${ to } ${ suffix } \\) ${ date } ` ;
6768const features = EOL + EOL + EOL + '### Features' + EOL ;
6869const fixes = EOL + EOL + EOL + '### Bug Fixes' + EOL ;
69- const commit = ( type , name ) => EOL + `\\* \\*\\*${ name } :\\*\\* ${ type } ${ name } ${ sha } ` ;
70+ const commit = ( type , name , url = '' ) => EOL + `\\* \\*\\*${ name } :\\*\\* ${ type } ${ name } ${ url ? `\\(\\[ ${ sha } \\]\\( ${ url } /commit/ ${ shaLong } \\)\\)` : sha } ` ;
7071
7172const nl = value => value . split ( / \r \n | \r | \n / g) . join ( EOL ) ;
7273
@@ -433,3 +434,20 @@ test('should pass parserOpts and writerOpts', async () => {
433434 assert . match ( changelog , / f i x / ) ;
434435 assert . match ( changelog , / f e a t / ) ;
435436} ) ;
437+
438+ test ( 'should generate changelog with origin urls' , async ( ) => {
439+ setup ( ) ;
440+
441+ const url = 'https://github.com/release-it/conventional-changelog' ;
442+ sh . exec ( `git tag 1.0.0` ) ;
443+ sh . exec ( `git remote add origin ${ url } ` )
444+ add ( 'fix' , 'bar' ) ;
445+ add ( 'feat' , 'baz' ) ;
446+
447+ const options = getOptions ( { preset } ) ;
448+ const { changelog } = await runTasks ( ...options ) ;
449+ const title = header ( '1.0.0' , '1.1.0' , '' , url ) ;
450+ const bar = commit ( 'fix' , 'bar' , url ) ;
451+ const baz = commit ( 'feat' , 'baz' , url ) ;
452+ assert . match ( nl ( changelog ) , new RegExp ( '^' + title + fixes + bar + features + baz + '$' ) ) ;
453+ } ) ;
0 commit comments