Skip to content

Commit aa2587e

Browse files
committed
chore(fast-paced commit): refactoring workflow to allow faster commits
1 parent 9c766f2 commit aa2587e

File tree

3 files changed

+29
-32
lines changed

3 files changed

+29
-32
lines changed

commit_helper/utils/file_handler.py

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from .utils import gen_co_author
66
from .utils import dump_convention
77
from .utils import validate_commiter_file
8+
from .utils import handle_conventioned_commit
89
from .colors import RESET
910
from .colors import NOTIFY_COLOR
1011
from .text_utils import debug
@@ -37,28 +38,12 @@ def handle_file_based_commit(file_path, debug_mode, args):
3738
commit_msg = custom_convention(tag, msg, config, debug_mode)
3839

3940
else:
40-
commit_msg = handle_conventioned_commit(convention)
41+
notify('You are using the %s convention' % convention)
42+
commit_msg = handle_conventioned_commit(convention, args)
4143

4244
commit_msg += gen_co_author(args.co_author)
4345
debug('commit message', commit_msg, debug_mode)
4446
system('git commit -m "%s"' % commit_msg)
4547

4648
except YAMLError as err:
4749
print(err)
48-
49-
50-
def handle_conventioned_commit(convention):
51-
notify('You are using the %s convention' % convention)
52-
tag, msg = get_text()
53-
54-
if convention == 'angular' or convention == 'karma':
55-
context = get_context()
56-
commit_message = angular_convention(tag, msg, context)
57-
58-
elif convention == 'changelog':
59-
commit_message = changelog_convention(tag, msg)
60-
61-
elif convention == 'symphony':
62-
commit_message = symphony_convention(tag, msg)
63-
64-
return commit_message

commit_helper/utils/flag_commit_handler.py

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# utils imports
33
from .utils import create_file
44
from .utils import gen_co_author
5+
from .utils import handle_conventioned_commit
56
from .text_utils import debug
67
from .text_utils import get_text
78
from .text_utils import get_context
@@ -27,21 +28,9 @@ def convention_flag_handler(args, debug_mode):
2728
create_file('none', args.no_file)
2829

2930
else:
30-
tag, msg = handle_tag_message_args(args.tag, args.message)
31-
32-
if convention == 'angular' or convention == 'karma':
33-
context = handle_context_arg(args.context)
34-
commit_message = angular_convention(tag, msg, context)
35-
create_file(convention, args.no_file)
36-
37-
elif convention == 'changelog':
38-
commit_message = changelog_convention(tag, msg)
39-
create_file(convention, args.no_file)
40-
41-
elif convention == 'symphony':
42-
commit_message = symphony_convention(tag, msg)
43-
create_file(convention, args.no_file)
31+
commit_message = handle_conventioned_commit(convention, args)
4432

33+
create_file(convention, args.no_file)
4534
commit_message += gen_co_author(args.co_author)
4635
debug('commit message', commit_message, debug_mode)
4736
system('git commit -m "%s"' % commit_message)

commit_helper/utils/utils.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
import sys
22
import argparse
33
from yaml import dump
4+
from .text_utils import handle_context_arg
5+
from .text_utils import handle_tag_message_args
6+
from commit_helper.conventions.karma_angular import angular_convention
7+
from commit_helper.conventions.changelog import changelog_convention
8+
from commit_helper.conventions.symphony_cmf import symphony_convention
9+
from commit_helper.conventions.no_convention import just_message
10+
411

512
supported_conventions = [
613
"angular",
@@ -82,3 +89,19 @@ def validate_commiter_file(stream_file): # pragma: no cover
8289
if stream_file['commit_pattern'] is None or stream_file['context'] is None:
8390
print("Error: Your commiter file lacks a commit_pattern or context!")
8491
sys.exit(0)
92+
93+
94+
def handle_conventioned_commit(convention, args):
95+
tag, msg = handle_tag_message_args(args.tag, args.message)
96+
97+
if convention == 'angular' or convention == 'karma':
98+
context = handle_context_arg(args.context)
99+
commit_message = angular_convention(tag, msg, context)
100+
101+
elif convention == 'changelog':
102+
commit_message = changelog_convention(tag, msg)
103+
104+
elif convention == 'symphony':
105+
commit_message = symphony_convention(tag, msg)
106+
107+
return commit_message

0 commit comments

Comments
 (0)