Skip to content

Commit 3804176

Browse files
krotscheckmarionebl
authored andcommitted
feat(core): ignore version commits with footers
1 parent 87d1036 commit 3804176

File tree

2 files changed

+39
-17
lines changed

2 files changed

+39
-17
lines changed

@commitlint/core/src/library/is-ignored.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@ const WILDCARDS = [
77
),
88
c => c.match(/^(R|r)evert (.*)/),
99
c => c.match(/^(fixup|squash)!/),
10-
c => semver.valid(c.trim())
10+
c =>
11+
semver.valid(
12+
c
13+
.split('\n')
14+
.shift()
15+
.trim()
16+
)
1117
];
1218

1319
export default function isIgnored(commit = '') {

@commitlint/core/src/library/is-ignored.test.js

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,38 @@ test('should return true for revert commits', t => {
3434
);
3535
});
3636

37-
test('should return true for npm version commits', t => {
38-
t.true(isIgnored(`0.0.1`));
39-
t.true(isIgnored(`0.1.0`));
40-
t.true(isIgnored(`1.0.0`));
41-
t.true(isIgnored(`0.0.1-alpha`));
42-
t.true(isIgnored(`0.0.1-some-crazy-tag`));
43-
t.true(isIgnored(`0.0.1-0`));
44-
t.true(isIgnored(`0.0.1-999`));
45-
t.true(isIgnored(`0.0.1-alpha.0`));
46-
t.true(isIgnored(`0.0.1-alpha.999`));
47-
t.true(isIgnored(`0.0.1-some-crazy-tag.0`));
48-
t.true(isIgnored(`0.0.1-some-crazy-tag.999`));
49-
t.true(isIgnored(`0.0.1-1e69d54`));
50-
t.true(isIgnored(`v0.0.1`));
51-
t.true(isIgnored(` v3.0.0`));
52-
});
37+
const versionCommitInputs = [
38+
'0.0.1',
39+
'0.1.0',
40+
'1.0.0',
41+
'0.0.1-alpha',
42+
'0.0.1-some-crazy-tag',
43+
'0.0.1-0',
44+
'0.0.1-999',
45+
'0.0.1-alpha.0',
46+
'0.0.1-alpha.999',
47+
'0.0.1-some-crazy-tag.0',
48+
'0.0.1-some-crazy-tag.999',
49+
'0.0.1-1e69d54',
50+
'v0.0.1',
51+
' v3.0.0'
52+
];
53+
for (let i = 0, len = versionCommitInputs.length; i < len; i++) {
54+
const input = versionCommitInputs[i];
55+
const commitMsg1 = input;
56+
const commitMsg2 = `${input}\n\nSigned-off-by: Developer <[email protected]>`;
57+
const commitMsg3 = `${input}\n\nChange-Id: I895114872a515a269487a683124b63303818e19c`;
58+
const commitMsg4 = `${input}\n\nSigned-off-by: Developer <[email protected]>\nChange-Id: I895114872a515a269487a683124b63303818e19c`;
59+
60+
console.log(commitMsg1, commitMsg2, commitMsg3, commitMsg4);
61+
62+
test(`should return true for version commit permutations of '${input}'`, t => {
63+
t.true(isIgnored(commitMsg1));
64+
t.true(isIgnored(commitMsg2));
65+
t.true(isIgnored(commitMsg3));
66+
t.true(isIgnored(commitMsg4));
67+
});
68+
}
5369

5470
test('should return true fixup commits', t => {
5571
t.true(isIgnored('fixup! initial commit'));

0 commit comments

Comments
 (0)