From f3beda196ed1873de752a84d435b812caa448717 Mon Sep 17 00:00:00 2001 From: Mario Nebl Date: Thu, 2 Nov 2017 21:51:29 +0100 Subject: [PATCH] fix(core): ignore comments * switch to patched fork of conventional-commits-parser * add test cases for comments * fixes #78 --- @commitlint/core/package.json | 2 +- @commitlint/core/src/library/parse.js | 2 +- @commitlint/core/src/library/parse.test.js | 16 +++++++++++++++ yarn.lock | 24 +++++++++++----------- 4 files changed, 30 insertions(+), 14 deletions(-) diff --git a/@commitlint/core/package.json b/@commitlint/core/package.json index c70b857b30..523dbb55d4 100644 --- a/@commitlint/core/package.json +++ b/@commitlint/core/package.json @@ -82,12 +82,12 @@ "xo": "0.18.2" }, "dependencies": { + "@marionebl/conventional-commits-parser": "^3.0.0", "@marionebl/git-raw-commits": "^1.2.0", "@marionebl/sander": "^0.6.0", "babel-runtime": "^6.23.0", "chalk": "^2.0.1", "conventional-changelog-angular": "^1.3.3", - "conventional-commits-parser": "^1.3.0", "cosmiconfig": "^3.0.1", "find-up": "^2.1.0", "lodash": "^4.17.4", diff --git a/@commitlint/core/src/library/parse.js b/@commitlint/core/src/library/parse.js index fc0e5b16a6..39af1026aa 100644 --- a/@commitlint/core/src/library/parse.js +++ b/@commitlint/core/src/library/parse.js @@ -1,4 +1,4 @@ -import {sync} from 'conventional-commits-parser'; +import {sync} from '@marionebl/conventional-commits-parser'; import defaultChangelogOpts from 'conventional-changelog-angular'; export default parse; diff --git a/@commitlint/core/src/library/parse.test.js b/@commitlint/core/src/library/parse.test.js index 0df838de31..b4ec58469c 100644 --- a/@commitlint/core/src/library/parse.test.js +++ b/@commitlint/core/src/library/parse.test.js @@ -104,3 +104,19 @@ test('supports scopes with /', async t => { t.is(actual.scope, 'some/scope'); t.is(actual.subject, 'subject'); }); + +test('ignores comments', async t => { + const message = 'type(some/scope): subject\n# some comment'; + const actual = await parse(message); + t.is(actual.body, null); + t.is(actual.footer, null); + t.is(actual.subject, 'subject'); +}); + +test('registers inline #', async t => { + const message = + 'type(some/scope): subject #reference\n# some comment\nthings #reference'; + const actual = await parse(message); + t.is(actual.subject, 'subject #reference'); + t.is(actual.body, 'things #reference'); +}); diff --git a/yarn.lock b/yarn.lock index 1460da4e77..32a2cbddff 100644 --- a/yarn.lock +++ b/yarn.lock @@ -59,6 +59,18 @@ dependencies: arrify "^1.0.1" +"@marionebl/conventional-commits-parser@^3.0.0": + version "3.0.0" + resolved "https://registry.npmjs.org/@marionebl/conventional-commits-parser/-/conventional-commits-parser-3.0.0.tgz#9da29b4d2c8f05c0f9cdd02936713b8096c958d3" + dependencies: + JSONStream "^1.0.4" + is-text-path "^1.0.0" + lodash "^4.2.1" + meow "^3.3.0" + split2 "^2.0.0" + through2 "^2.0.0" + trim-off-newlines "^1.0.0" + "@marionebl/git-raw-commits@^1.2.0": version "1.2.0" resolved "https://registry.npmjs.org/@marionebl/git-raw-commits/-/git-raw-commits-1.2.0.tgz#7cd8a6dfc09a96df98d8fbe9175c5971cc07c82b" @@ -1849,18 +1861,6 @@ conventional-commits-filter@^1.0.0: is-subset "^0.1.1" modify-values "^1.0.0" -conventional-commits-parser@^1.3.0: - version "1.3.0" - resolved "https://registry.npmjs.org/conventional-commits-parser/-/conventional-commits-parser-1.3.0.tgz#e327b53194e1a7ad5dc63479ee9099a52b024865" - dependencies: - JSONStream "^1.0.4" - is-text-path "^1.0.0" - lodash "^4.2.1" - meow "^3.3.0" - split2 "^2.0.0" - through2 "^2.0.0" - trim-off-newlines "^1.0.0" - conventional-commits-parser@^2.0.0: version "2.0.0" resolved "https://registry.npmjs.org/conventional-commits-parser/-/conventional-commits-parser-2.0.0.tgz#71d01910cb0a99aeb20c144e50f81f4df3178447"