Skip to content

Commit

Permalink
add external authors to the release notes
Browse files Browse the repository at this point in the history
  • Loading branch information
pooya parsa committed Apr 15, 2019
1 parent 6db8ec9 commit 6927f6d
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions scripts/changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import consola from 'consola'
import execa from 'execa'
import groupBy from 'lodash/groupBy'
import sortBy from 'lodash/sortBy'
import uniq from 'lodash/uniq'
import { writeFile } from 'fs-extra'

const types = {
Expand All @@ -15,6 +16,19 @@ const types = {
test: { title: 'Tests' }
}

const knownAuthors = [
'chopin',
'parsa',
'clark',
'galvez',
'lichter',
'molotkov',
'marrec',
'pim'
]

const isKnownAuthor = name => Boolean(knownAuthors.find(n => name.toLowerCase().includes(n)))

const allowedTypes = Object.keys(types)

async function main() {
Expand Down Expand Up @@ -50,11 +64,12 @@ async function getLastGitTag() {
}

async function getGitDiff(from, to) {
const r = await execCommand('git', ['--no-pager', 'log', `${from}...${to}`, '--pretty=%s|%h'])
// # https://git-scm.com/docs/pretty-formats
const r = await execCommand('git', ['--no-pager', 'log', `${from}...${to}`, '--pretty=%s|%h|%an|%ae'])
return r.split('\n').map((line) => {
const [message, commit] = line.split('|')
const [message, commit, authorName, authorEmail] = line.split('|')

return { message, commit }
return { message, commit, authorName, authorEmail }
})
}

Expand All @@ -81,11 +96,11 @@ function parseCommits(commits) {
type = type.split('(')[0]

return {
...commit,
message,
type,
scope,
references,
commit: commit.commit
references
}
})
}
Expand All @@ -106,6 +121,12 @@ function generateMarkDown(commits) {
markdown += sortBy(group, 'scope').map(formatCommitForMarkdown).join('\n')
}

const authors = sortBy(uniq(commits.map(commit => commit.authorName).filter(an => !isKnownAuthor(an))))
if (authors.length) {
markdown += '\n\n' + '## ' + 'Thanks to' + '\n\n'
markdown += authors.map(name => '- ' + name).join('\n')
}

return markdown.trim()
}

Expand Down

0 comments on commit 6927f6d

Please sign in to comment.