@@ -2,6 +2,7 @@ import consola from 'consola'
22import execa from 'execa'
33import groupBy from 'lodash/groupBy'
44import sortBy from 'lodash/sortBy'
5+ import uniq from 'lodash/uniq'
56import { writeFile } from 'fs-extra'
67
78const types = {
@@ -15,6 +16,19 @@ const types = {
1516 test : { title : 'Tests' }
1617}
1718
19+ const knownAuthors = [
20+ 'chopin' ,
21+ 'parsa' ,
22+ 'clark' ,
23+ 'galvez' ,
24+ 'lichter' ,
25+ 'molotkov' ,
26+ 'marrec' ,
27+ 'pim'
28+ ]
29+
30+ const isKnownAuthor = name => Boolean ( knownAuthors . find ( n => name . toLowerCase ( ) . includes ( n ) ) )
31+
1832const allowedTypes = Object . keys ( types )
1933
2034async function main ( ) {
@@ -50,11 +64,12 @@ async function getLastGitTag() {
5064}
5165
5266async function getGitDiff ( from , to ) {
53- const r = await execCommand ( 'git' , [ '--no-pager' , 'log' , `${ from } ...${ to } ` , '--pretty=%s|%h' ] )
67+ // # https://git-scm.com/docs/pretty-formats
68+ const r = await execCommand ( 'git' , [ '--no-pager' , 'log' , `${ from } ...${ to } ` , '--pretty=%s|%h|%an|%ae' ] )
5469 return r . split ( '\n' ) . map ( ( line ) => {
55- const [ message , commit ] = line . split ( '|' )
70+ const [ message , commit , authorName , authorEmail ] = line . split ( '|' )
5671
57- return { message, commit }
72+ return { message, commit, authorName , authorEmail }
5873 } )
5974}
6075
@@ -81,11 +96,11 @@ function parseCommits(commits) {
8196 type = type . split ( '(' ) [ 0 ]
8297
8398 return {
99+ ...commit ,
84100 message,
85101 type,
86102 scope,
87- references,
88- commit : commit . commit
103+ references
89104 }
90105 } )
91106}
@@ -106,6 +121,12 @@ function generateMarkDown(commits) {
106121 markdown += sortBy ( group , 'scope' ) . map ( formatCommitForMarkdown ) . join ( '\n' )
107122 }
108123
124+ const authors = sortBy ( uniq ( commits . map ( commit => commit . authorName ) . filter ( an => ! isKnownAuthor ( an ) ) ) )
125+ if ( authors . length ) {
126+ markdown += '\n\n' + '## ' + 'Thanks to' + '\n\n'
127+ markdown += authors . map ( name => '- ' + name ) . join ( '\n' )
128+ }
129+
109130 return markdown . trim ( )
110131}
111132
0 commit comments