Skip to content
This repository was archived by the owner on Sep 22, 2025. It is now read-only.

Commit 851b86f

Browse files
committed
major: add new commit type for breaking change
add major as new commit type for breaking change commits so that major version gets updated BREAKING CHANGE: this is a test
1 parent 3e0ed5b commit 851b86f

File tree

5 files changed

+94
-17
lines changed

5 files changed

+94
-17
lines changed

.husky/prepare-commit-msg

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,31 @@
11
#!/usr/bin/env node
22

3-
// hook that validates that a 'BREAKING CHANGE' commit message contains an exclamation mark (!) in
4-
// its subject (just after the commit type(scope))
3+
// hook that validates that a major change commit contains the mention 'BREAKING CHANGE'
54

65
const fs = require('fs');
76

87
const message = fs.readFileSync(process.argv[2], 'utf8').trim();
98

10-
if (!message.includes('BREAKING CHANGE') || message.includes('chore(release)')) {
9+
if (message.includes('chore(release)')) {
1110
process.exit(0);
1211
}
1312

1413
const commitMsgSplitted = message.split('\n');
1514
const commitSubject = commitMsgSplitted[0];
1615

17-
// use the following when MGW-540 is done
18-
// const commitEmojiAndTypeRegex = /^:[A-Za-z]*: [A-Za-z()]*!:/g;
19-
// const commitEmojiAndType = commitSubject.match(commitEmojiAndTypeRegex);
16+
const majorCommitTypeRegex = /^major[(a-zA-Z.)]*:/g;
17+
const majorCommitType = commitSubject.match(majorCommitTypeRegex);
2018

21-
const commitTypeRegex = /^[A-Za-z()]*!:/g;
22-
const commitType = commitSubject.match(commitTypeRegex);
19+
if (!majorCommitType || majorCommitType.length === 0) {
20+
process.exit(0);
21+
}
2322

24-
// if (!commitEmojiAndType || commitEmojiAndType.length === 0) { use the following when MGW-540 is done
25-
if (!commitType || commitType.length === 0) {
23+
if (
24+
!message.includes('BREAKING CHANGE:') &&
25+
!message.includes('BREAKING CHANGES:')
26+
) {
2627
console.log(
27-
"❌ Wrong commit format for a BREAKING CHANGE. Please add an exclamation mark '!' just after your commit type(scope).\nFor example: :sparkles: feat(ui)!: new component"
28+
"❌ Wrong commit format for a major change. Please mention 'BREAKING CHANGE:' at the beginning of the commit footer and explain the breaking change."
2829
);
2930

3031
process.exit(1);

CONTRIBUTING.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,15 @@ We follow the [Conventional Commit convention](https://www.conventionalcommits.o
7070
- `build`: changes to the build process.
7171
- `chore`: any chore project changes
7272

73-
If your changes introduce any breaking changes, make sure to specify an exclamation point (!) after your commit type(scope) and 'BREAKING CHANGE' in the footer of your commit message. Refer to [Conventional Commit convention](https://www.conventionalcommits.org/en/v1.0.0-beta.4/) for more details.
73+
If your changes introduce any breaking changes, you have to specify 'major' as commit type.
7474

7575
Some guidelines to follow when writting commit messages:
7676
- Commit message needs to start with a present tense verb. For example, write: 'add new component' instead of 'added new component'
7777
- Provide a message body that explains the changes you have made and why they are needed
7878
- when your change is a BREAKING CHANGE:
79-
- put an '!' mark right after the subject/scope. For example:
80-
- feat!: add a new feature
81-
- fix(PBSCDropdown)!: remvove a property
79+
- put 'major' as commit type. For example:
80+
- major: add new component
81+
- major(PBSCDropdown)!: remvove a property
8282
- provide a message in the footer that begins with 'BREAKING CHANGE:'
8383

8484
Our pre-commit hooks verify that your commit message matches this format when committing.

commitlint.config.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,23 @@
1-
module.exports = { extends: ['@commitlint/config-conventional'] };
1+
module.exports = {
2+
extends: ['@commitlint/config-conventional'],
3+
rules: {
4+
'type-enum': [
5+
2,
6+
'always',
7+
[
8+
'feat',
9+
'fix',
10+
'docs',
11+
'style',
12+
'major',
13+
'ci',
14+
'build',
15+
'chore',
16+
'perf',
17+
'test',
18+
'revert',
19+
'refactor',
20+
],
21+
],
22+
},
23+
};

package.json

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,57 @@
154154
},
155155
"config": {
156156
"commitizen": {
157-
"path": "./node_modules/cz-conventional-changelog"
157+
"path": "./node_modules/cz-conventional-changelog",
158+
"types": {
159+
"feat": {
160+
"description": "A new feature",
161+
"title": "Feature"
162+
},
163+
"fix": {
164+
"description": "A bug fix",
165+
"title": "Bug Fix"
166+
},
167+
"docs": {
168+
"description": "Documentation only changes",
169+
"title": "Documentation"
170+
},
171+
"style": {
172+
"description": "Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)",
173+
"title": "Style"
174+
},
175+
"refactor": {
176+
"description": "A code change that neither fixes a bug nor adds a feature",
177+
"title": "Refactor"
178+
},
179+
"perf": {
180+
"description": "A code change that improves performance",
181+
"title": "Performance"
182+
},
183+
"test": {
184+
"description": "Adding missing tests or correcting existing tests",
185+
"title": "Tests"
186+
},
187+
"major": {
188+
"description": "A breaking change change that should introduce major version upgrade",
189+
"title": "Major change"
190+
},
191+
"build": {
192+
"description": "Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)",
193+
"title": "Build"
194+
},
195+
"ci": {
196+
"description": "Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)",
197+
"title": "CI"
198+
},
199+
"chore": {
200+
"description": "Other changes that don't modify src or test files",
201+
"title": "Chore"
202+
},
203+
"revert": {
204+
"description": "Reverts a previous commit",
205+
"title": "Revert"
206+
}
207+
}
158208
}
159209
}
160210
}

release.config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ module.exports = {
4242
type: 'revert',
4343
release: 'patch',
4444
},
45+
{
46+
type: 'major',
47+
release: 'major',
48+
},
4549
],
4650
parserOpts: {
4751
noteKeywords: ['BREAKING CHANGE', 'BREAKING CHANGES'],

0 commit comments

Comments
 (0)