Skip to content

Commit db2ad84

Browse files
committed
fix(changelog): ignore non-conventional commits insert
1 parent ef2efde commit db2ad84

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

src/changelog.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ import { setChangelog } from './utils';
55
import { getGeneriConfig } from './generi';
66
import conventional from './defines/conventional-commits.json';
77

8+
const getValidConventionalCommit = (str: string) => {
9+
return conventional.type.some((c) => str.startsWith(c));
10+
};
11+
812
const getEmoji = (str: string): string => {
913
const emojis: GeneriEmoticon[] = [
1014
['feat', '🎉 '],
@@ -38,13 +42,14 @@ const setSubHeader = (commit: Commit) => {
3842

3943
const setBasic = (commit: Commit) => {
4044
const generi = getGeneriConfig();
41-
let result: any;
45+
let result: string[] | string;
4246

4347
if (generi.commits === 'conventional-commits') {
4448
result = commit.summary
4549
.split(/:(.+)/)
4650
.filter((part) => part)
47-
.map((part) => part.trimStart());
51+
.map((part) => part.trimStart())
52+
.filter((part) => getValidConventionalCommit(part));
4853
} else {
4954
result = commit.summary;
5055
}
@@ -70,7 +75,7 @@ const setBasic = (commit: Commit) => {
7075

7176
if (isTagCommit(commit)) return '';
7277

73-
return '* ' + result.trim() + ` [${commit.sha}]` + '\n';
78+
return '* ' + (result as string).trim() + ` [${commit.sha}]` + '\n';
7479
};
7580

7681
const isConventionalCommit = (commit: Commit) => {

0 commit comments

Comments
 (0)