Skip to content

Commit dc9ab8f

Browse files
committed
fix: further switch to Convention Commits
1 parent 90bd769 commit dc9ab8f

File tree

3 files changed

+22
-18
lines changed

3 files changed

+22
-18
lines changed

.releaserc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
}],
1313
["@semantic-release/git", {
1414
"assets": ["dist", "CHANGELOG.md"],
15-
"message": "chore: Release ${nextRelease.version} [skip ci]"
15+
"message": "chore: release ${nextRelease.version} [skip ci]"
1616
}]
1717
]
1818
}

src/validatePrTitle.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,17 @@ module.exports = async function validatePrTitle(
3030
}
3131
const result = parser(prTitle, parserOpts);
3232

33+
function removeCapitalLetter(text) {
34+
return text.charAt(0).toLowerCase() + text.substring(1);
35+
}
36+
3337
function printAvailableTypes() {
3438
return `Available types:\n${types
3539
.map((type) => {
3640
let bullet = ` - ${type}`;
3741
3842
if (types === defaultTypes) {
39-
bullet += `: ${conventionalCommitTypes.types[type].description}`;
43+
bullet += `: ${removeCapitalLetter(conventionalCommitTypes.types[type].description)}`;
4044
}
4145
4246
return bullet;

src/validatePrTitle.test.js

+16-16
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ const validatePrTitle = require('./validatePrTitle');
22

33
it('allows valid PR titles that use the default types', async () => {
44
const inputs = [
5-
'fix: Fix bug',
6-
'fix!: Fix bug',
7-
'feat: Add feature',
8-
'feat!: Add feature',
9-
'refactor: Internal cleanup'
5+
'fix: fix bug',
6+
'fix!: fix bug',
7+
'feat: add feature',
8+
'feat!: add feature',
9+
'refactor: internal cleanup'
1010
];
1111

1212
for (let index = 0; index < inputs.length; index++) {
@@ -40,15 +40,15 @@ it('throws for PR titles with an unknown type', async () => {
4040

4141
describe('defined scopes', () => {
4242
it('allows a missing scope by default', async () => {
43-
await validatePrTitle('fix: Bar');
43+
await validatePrTitle('fix: bar');
4444
});
4545

4646
it('allows all scopes by default', async () => {
4747
await validatePrTitle('fix(core): Bar');
4848
});
4949

5050
it('allows a missing scope when custom scopes are defined', async () => {
51-
await validatePrTitle('fix: Bar', {scopes: ['foo']});
51+
await validatePrTitle('fix: bar', {scopes: ['foo']});
5252
});
5353

5454
it('allows a matching scope', async () => {
@@ -132,12 +132,12 @@ describe('defined scopes', () => {
132132

133133
it('throws when a scope is missing', async () => {
134134
await expect(
135-
validatePrTitle('fix: Bar', {
135+
validatePrTitle('fix: bar', {
136136
scopes: ['foo', 'bar'],
137137
requireScope: true
138138
})
139139
).rejects.toThrow(
140-
'No scope found in pull request title "fix: Bar". Scope must match one of: foo, bar.'
140+
'No scope found in pull request title "fix: bar". Scope must match one of: foo, bar.'
141141
);
142142
});
143143
});
@@ -253,12 +253,12 @@ describe('defined scopes', () => {
253253

254254
it('throws when a scope is missing', async () => {
255255
await expect(
256-
validatePrTitle('fix: Bar', {
256+
validatePrTitle('fix: bar', {
257257
requireScope: true
258258
})
259259
).rejects.toThrow(
260260
// Should make no mention of any available scope
261-
/^No scope found in pull request title "fix: Bar".$/
261+
/^No scope found in pull request title "fix: bar".$/
262262
);
263263
});
264264
});
@@ -277,9 +277,9 @@ describe('custom types', () => {
277277

278278
it('throws for PR titles with an unknown type', async () => {
279279
await expect(
280-
validatePrTitle('fix: Foobar', {types: ['foo', 'bar']})
280+
validatePrTitle('fix: foobar', {types: ['foo', 'bar']})
281281
).rejects.toThrow(
282-
'Unknown release type "fix" found in pull request title "fix: Foobar".'
282+
'Unknown release type "fix" found in pull request title "fix: foobar".'
283283
);
284284
});
285285
});
@@ -332,11 +332,11 @@ describe('description validation', () => {
332332

333333
it('throws for only partial matches', async () => {
334334
await expect(
335-
validatePrTitle('fix: Foobar', {
336-
subjectPattern: 'Foo'
335+
validatePrTitle('fix: foobar', {
336+
subjectPattern: 'foo'
337337
})
338338
).rejects.toThrow(
339-
'The subject "Foobar" found in pull request title "fix: Foobar" isn\'t an exact match for the configured pattern "Foo". Please provide a subject that matches the whole pattern exactly.'
339+
'The subject "foobar" found in pull request title "fix: foobar" isn\'t an exact match for the configured pattern "foo". Please provide a subject that matches the whole pattern exactly.'
340340
);
341341
});
342342

0 commit comments

Comments
 (0)