Skip to content

Commit

Permalink
test: fix coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
scarf005 authored and Ezard committed Dec 29, 2024
1 parent 3216c9d commit 23f4cb7
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions functions/src/is-message-semantic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { types } from 'conventional-commit-types';
import { Config } from './config';

const commitTypes = Object.keys(types);
const validTypeSyntaxRegex = /^.*: [^ ].*$/;

export function isMessageSemantic({
scopes,
Expand All @@ -25,10 +26,6 @@ export function isMessageSemantic({
return false;
}

if (!/^.*: [^ ].*$/.test(message)) {
return false;
}

let commit: ConventionalChangelogCommit;
try {
commit = toConventionalChangelogFormat(parser(message));
Expand All @@ -38,7 +35,8 @@ export function isMessageSemantic({

const { scope, type } = commit;
const isScopeValid = !scopes || !scope || scope.split(/, ?/).every(scope => scopes.includes(scope));
const isTypeValid = (types.length > 0 ? types : commitTypes).includes(type);
const isTypeValid = (types.length > 0 ? types : commitTypes).includes(type) && validTypeSyntaxRegex.test(message);

return isTypeValid && isScopeValid;
};
}

0 comments on commit 23f4cb7

Please sign in to comment.