Skip to content

Commit 2c57914

Browse files
committed
fix: fix partial type matching
Closes #11
1 parent e3f0939 commit 2c57914

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

conventional_precommit_linter/hook.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from .helpers import _color_orange
1212
from .helpers import _color_purple
1313

14+
DEFAULT_TYPES = ['change', 'ci', 'docs', 'feat', 'fix', 'refactor', 'remove', 'revert']
1415

1516
rules_output_status = {
1617
'empty_message': False,
@@ -28,16 +29,16 @@
2829

2930

3031
def get_allowed_types(args: argparse.Namespace) -> List[str]:
31-
default_types = ['change', 'ci', 'docs', 'feat', 'fix', 'refactor', 'remove', 'revert']
3232
# Provided types take precedence over default types
33-
types: List[str] = args.types[0].split(',') if args.types else default_types
34-
return types
33+
types: List[str] = args.types[0].split(',') if args.types else DEFAULT_TYPES
34+
return [commit_type.strip() for commit_type in types]
35+
3536

3637

3738
def get_allowed_scopes(args: argparse.Namespace) -> List[str]:
3839
default_scopes: List[str] = []
3940
scopes: List[str] = args.scopes[0].split(',') if args.scopes else default_scopes
40-
return scopes
41+
return [scope.strip() for scope in scopes]
4142

4243

4344
def read_commit_message(file_path: str) -> str:

tests/test_default_args.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,11 @@ def commit_message_id(commit_message): # pylint: disable=redefined-outer-name
128128
'Fix(bt): Added new feature with change\n\nThis feature adds functionality',
129129
{'error_type': True},
130130
),
131+
(
132+
# Expected Fail: partial type
133+
'chan: This is commit message with partial type',
134+
{'error_type': True},
135+
),
131136
(
132137
# Expected FAIL: missing blank line between 'summary' and 'body'
133138
'change: Added new feature with change\nThis feature adds functionality',

0 commit comments

Comments
 (0)