Pass commit data into this function to format a markdown commit note. Data structure is based on what Github's compare endpoint returns.
This is useful for generating a changelog for release notes based on git activity.
Based on response from Github's compareCommits endpoint.
var dataExample = [{
author: {
login: 'brandonsheppard',
html_url: 'https://github.com/brandonsheppard'
},
commit: {
message: 'Etiam porta sem malesuada magna mollis euismod.'
},
sha: '685eb53d517a335d0d7a654472c9553679161ec8',
html_url: 'https://github.com/my_repository/685eb53d517a335d0d7a654472c9553679161ec8'
},{
author: {
login: 'philconnah',
html_url: 'https://github.com/philconnah'
},
commit: {
message: 'Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.'
},
sha: 'e34784dcbc43873c6900803db2e29c3555830e59',
html_url: 'https://github.com/my_repository/e34784dcbc43873c6900803db2e29c3555830e59'
}]
formatNotes(dataExample)
- [brandonsheppard](https://github.com/brandonsheppard) Etiam porta sem malesuada magna mollis euismod. [685eb53d517a335d0d7a654472c9553679161ec8](https://github.com/my_repository/685eb53d517a335d0d7a654472c9553679161ec8)
- [philconnah](https://github.com/philconnah) Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. [e34784dcbc43873c6900803db2e29c3555830e59](https://github.com/my_repository/e34784dcbc43873c6900803db2e29c3555830e59)
function formatNotes(data){
return data.map(commit => `- [${commit.author.login}](${commit.author.html_url}) ${commit.commit.message} [${commit.sha}](${commit.html_url})`).join('\n')
}