Skip to content

Commit a38996f

Browse files
committed
<add> : final custom commit convention
1 parent e0b62c5 commit a38996f

File tree

4 files changed

+15
-14
lines changed

4 files changed

+15
-14
lines changed

commit_helper/conventions/custom_convention_handler.py renamed to commit_helper/conventions/custom_convention.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,16 @@ def custom_convention(tag, message, config_file, debug_mode):
99
debug('pattern from file', config_file['commit_pattern'], debug_mode)
1010

1111
pattern = str(config_file['commit_pattern'] or '')
12-
debug('pattern processed', pattern, debug_mode)
12+
debug('pattern acquired', pattern, debug_mode)
1313

1414
context = ''
15-
1615
pattern = pattern.replace('tag', str(tag))
1716
pattern = pattern.replace('message', str(message))
18-
debug('pattern post replace', pattern, debug_mode)
1917

2018
if config_file['context']:
2119
context = get_context()
22-
pattern.replace('context', context)
20+
pattern = pattern.replace('context', context)
2321

22+
debug('pattern post replace', pattern, debug_mode)
2423
pattern += '\n'
2524
return pattern

commit_helper/utils/file_handler.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from yaml import YAMLError
44
# utils imports
55
from .utils import gen_co_author
6+
from .utils import dump_convention
67
from .utils import validate_commiter_file
78
from .text_utils import debug
89
from .text_utils import get_text
@@ -12,31 +13,32 @@
1213
from commit_helper.conventions.changelog import changelog_convention
1314
from commit_helper.conventions.symphony_cmf import symphony_convention
1415
from commit_helper.conventions.no_convention import just_message
16+
from commit_helper.conventions.custom_convention import custom_convention
1517

1618

1719
def handle_file_based_commit(file_path, debug_mode, args):
1820
with open(str(file_path), 'r') as stream:
1921
try:
2022
config = safe_load(stream)
2123
debug('convention from file', config['convention'], debug_mode)
22-
convention = dump_convention(config_file)
24+
convention = dump_convention(config)
2325

2426
if convention == 'none':
2527
print('You are not using a convention')
26-
commit_message = just_message()
28+
commit_msg = just_message()
2729

2830
elif convention == 'custom':
2931
print('You are using your custom convention')
3032
validate_commiter_file(config)
3133
tag, msg = get_text()
32-
commit_message = custom_convention(tag, msg, config)
34+
commit_msg = custom_convention(tag, msg, config, debug_mode)
3335

3436
else:
35-
commit_message = handle_conventioned_commit(convention)
37+
commit_msg = handle_conventioned_commit(convention)
3638

37-
commit_message += gen_co_author(args.co_author)
38-
debug('commit message', commit_message, debug_mode)
39-
system('git commit -m "%s"' % commit_message)
39+
commit_msg += gen_co_author(args.co_author)
40+
debug('commit message', commit_msg, debug_mode)
41+
system('git commit -m "%s"' % commit_msg)
4042

4143
except YAMLError as err:
4244
print(err)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
long_description_content_type='text/markdown',
1313
author='Andre de Sousa Costa Filho',
1414
author_email='andre.filho001@outlook.com',
15-
version='3.0.2',
15+
version='3.1.2',
1616
packages=find_packages(),
1717
entry_points={
1818
'console_scripts': [

test/test_conventions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import commit_helper.conventions.changelog as changelog
44
import commit_helper.conventions.symphony_cmf as symphony
55
import commit_helper.conventions.no_convention as no_convention
6-
import commit_helper.conventions.custom_convention_handler as custom
6+
import commit_helper.conventions.custom_convention as custom
77

88

99
def test_angular_convention_with_context():
@@ -30,7 +30,7 @@ def test_symphony_convention():
3030
raise AssertionError()
3131

3232

33-
def test_custom_convention_handler():
33+
def test_custom_convention():
3434
fyle = yaml.safe_load("""
3535
convention: custom
3636
commit_pattern: tag..:..message

0 commit comments

Comments
 (0)