Skip to content

Commit

Permalink
✨ Filter bookmark commit out (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
fabienjuif authored and bpetetot committed Oct 29, 2018
1 parent c4ffc59 commit 7858140
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
8 changes: 7 additions & 1 deletion packages/gitmoji-changelog-core/src/groupMapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ module.exports = [
'sparkles',
'tada',
'white_check_mark',
'bookmark',
'construction_worker',
'chart_with_upwards_trend',
'heavy_plus_sign',
Expand Down Expand Up @@ -75,6 +74,13 @@ module.exports = [
label: 'Security',
emojis: ['lock'],
},
{
group: 'useless',
label: 'Useless',
emojis: [
'bookmark',
],
},
{
group: 'misc',
label: 'Miscellaneous',
Expand Down
7 changes: 6 additions & 1 deletion packages/gitmoji-changelog-core/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,13 @@ function sanitizeVersion(version) {
})
}

function filterCommits(commits) {
return commits
.filter(commit => commit.group !== 'useless')
}

async function generateVersion({ from, to, version }) {
const commits = await getCommits(from, to)
const commits = filterCommits(await getCommits(from, to))
const lastCommitDate = getLastCommitDate(commits)

return {
Expand Down
30 changes: 30 additions & 0 deletions packages/gitmoji-changelog-core/src/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ const gitSemverTags = require('git-semver-tags')

const { generateChangelog } = require('./index')

const uselessCommit = {
hash: '460b79497ae7e791bc8ba8475bda8f0b93630dd3',
date: '2018-09-14T21:00:18+02:00',
subject: ':bookmark: Bump version to 1.9.2',
body: 'Yes!',
emoji: '🔖',
emojiCode: 'bookmark',
group: 'useless',
message: 'Bump version to 1.9.2',
}

const sparklesCommit = {
hash: 'c40ee8669ba7ea5151adc2942fa8a7fc98d9e23a',
date: '2018-08-28T10:06:00+02:00',
Expand Down Expand Up @@ -113,6 +124,25 @@ describe('changelog', () => {
])
})

it('should filter some commits out', async () => {
gitRawCommits.mockReset()
mockGroup([uselessCommit, lipstickCommit])

gitSemverTags.mockImplementation(cb => cb(null, []))

const { changes } = await generateChangelog({ mode: 'init' })

expect(changes).toEqual([
expect.objectContaining({
groups: [
expect.objectContaining({
commits: [lipstickCommit],
}),
],
}),
])
})

it('should throw an error if no commits', async () => {
mockNoCommits()

Expand Down

0 comments on commit 7858140

Please sign in to comment.