var execSync = require('child_process').execSync;
var getAuthor = (commitHash) => {
return execSync(`git show --quiet --format="%an" ${commitHash}`, { encoding: 'utf8' }).replace('\n', '');
}
module.exports = {
editChangelog: true,
parseFooterTags: true,
getGitReferenceFromVersion: 'v-prefix',
incrementVersion: 'semver',
updateVersion: 'cargo',
addEntryToChangelog: {
preset: 'prepend',
fromLine: 6
},
includeCommitWhen: (commit) => {
return !!commit.footer['change-type'];
},
getIncrementLevelFromCommit: (commit) => {
if (commit.footer['change-type']) {
return commit.footer['change-type'].trim();
}
},
transformTemplateData: (data) => {
data.commits.forEach((commit) => {
commit.subject = commit.footer['changelog-entry'] || commit.subject;
commit.author = getAuthor(commit.hash);
});
return data;
},
template: [
'## v{{version}} - {{moment date "Y-MM-DD"}}',
'',
'{{#each commits}}',
'{{#if this.author}}',
'* {{capitalize this.subject}} [{{this.author}}]',
'{{else}}',
'* {{capitalize this.subject}}',
'{{/if}}',
'{{/each}}'
].join('\n')
};